Suppress ObjC exceptions in OSXWindow::messageLoop.

Crashes have been seen inside the Cocoa-internal
NS_setFlushesWithDisplayLink function. Web searches indicate this is a
regression in macOS 11. See whether catching and ignoring these
exceptions improves stability.

Bug: angleproject:6570
Change-Id: Id0be68077163bf4e9f98189461eea016a35edd73
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3227697
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
This commit is contained in:
Kenneth Russell 2021-10-15 16:27:05 -07:00 коммит произвёл Angle LUCI CQ
Родитель eb9b3f8eb6
Коммит 4d5711291e
1 изменённых файлов: 22 добавлений и 11 удалений

Просмотреть файл

@ -711,6 +711,11 @@ void OSXWindow::messageLoop()
@autoreleasepool
{
while (true)
{
// TODO(http://anglebug.com/6570): @try/@catch is a workaround for
// exceptions being thrown from Cocoa-internal function
// NS_setFlushesWithDisplayLink starting in macOS 11.
@try
{
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantPast]
@ -727,6 +732,12 @@ void OSXWindow::messageLoop()
}
[NSApp sendEvent:event];
}
@catch (NSException *localException)
{
NSLog(@"*** OSXWindow discarding exception: <%@> %@", [localException name],
[localException reason]);
}
}
}
}