-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
Go version and OS
go version go1.8 darwin/amd64 (macOS Sierra 10.12.3)
### What did you do?
Run examples from ```golang.org/x/exp/shiny/example```:
```go get -tags=example golang.org/x/exp/shiny/example/imageview && $GOPATH/bin/imageview cat.jpg```
### What did you expect to see?
Working shiny windows using gldriver on SW renderers.
### What did you see instead?
On macOS, shiny applications fail during OpenGL setup when the system has no HW renderer available (e.g. in [overloaded GPU](https://developer.apple.com/library/content/qa/qa1502/_index.html) or VM scenarios).
The error occurs during glGenVertexArrays and is first checked when the Cocoa backend invokes glBindVertexArray:
```
panic: gldriver: glBindVertexArray failed: 1282
goroutine 18 [running, locked to thread]:
golang.org/x/exp/shiny/driver/gldriver.drawLoop(0xc4200f4000, 0x307)
/Users/fabian/Desktop/go/src/golang.org/x/exp/shiny/driver/gldriver/cocoa.go:146 +0x37a
created by golang.org/x/exp/shiny/driver/gldriver.preparedOpenGL
/Users/fabian/Desktop/go/src/golang.org/x/exp/shiny/driver/gldriver/cocoa.go:83 +0xf4
```
The issue is fixed by removing ```NSOpenGLPFAAccelerated``` from ```NSOpenGLPixelFormatAttribute```:
```
diff --git a/shiny/driver/gldriver/cocoa.m b/shiny/driver/gldriver/cocoa.m
index e8e863e..1e96e3f 100644
--- a/shiny/driver/gldriver/cocoa.m
+++ b/shiny/driver/gldriver/cocoa.m
@@ -284,7 +284,6 @@ uintptr_t doNewWindow(int width, int height, char* title) {
NSOpenGLPFAColorSize, 24,
NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFADepthSize, 16,
- NSOpenGLPFAAccelerated,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAllowOfflineRenderers,
0
```
Note that macOS will still [prefer HW accelerated rendering](https://developer.apple.com/reference/appkit/1436213-anonymous/nsopenglpfaaccelerated) with this change.
On Linux using the x11 gldriver (changing driver backend as in #12740), the built examples fail with
```
eglCreateContext failed: EGL_BAD_CONFIG
```
However, when exporting ```LIBGL_ALWAYS_SOFTWARE=1``` to force SW rendering, the example runs fine. The mesa GLES2 demos (e.g. es2gears_x11) work without that environment flag.
I can't provide a patch for Linux gldriver right now, but I will be glad to submit a CL for Darwin if this is agreed upon.Reactions are currently unavailable