cocoa-cb: fix crash with forced iGPU on some multi GPU systems

there were actually a few small problems. the fatalError() function
wasn't supposed to be called there and caused an "Illegal instruction".
this was replaced by a print and exit() call. the second problem was
that cocoa returns a kCGLBadPixelFormat instead of a kCGLBadAttribute
error, which broke our check, immediately exited our loop and no working
pixel format was ever created. the third problem was that macOS 10.12
didn't return any errors but also didn't return a pixel format, that
also broke our check. now the code checks for both cases.

Fixes #5631
This commit is contained in:
Akemi 2018-03-13 21:14:27 +01:00 committed by Kevin Mitchell
parent 12b90e744d
commit 749f5c8d65
1 changed files with 5 additions and 3 deletions

View File

@ -166,7 +166,7 @@ class VideoLayer: CAOpenGLLayer {
for index in stride(from: glAttributes.count-2, through: 4, by: -1) {
err = CGLChoosePixelFormat(glAttributes, &pix, &npix)
if err == kCGLBadAttribute {
if err == kCGLBadAttribute || err == kCGLBadPixelFormat || pix == nil {
glAttributes.remove(at: index)
} else {
break verLoop
@ -174,8 +174,10 @@ class VideoLayer: CAOpenGLLayer {
}
}
if err != kCGLNoError {
fatalError("Couldn't create CGL pixel format: \(CGLErrorString(err)) (\(err))")
if err != kCGLNoError || pix == nil {
let errS = String(cString: CGLErrorString(err))
print("Couldn't create CGL pixel format: \(errS) (\(err.rawValue))")
exit(1)
}
return pix!
}