Go-flutter: PlatformError: GLX: Failed to make context current

Created on 16 Feb 2019  Â·  4Comments  Â·  Source: go-flutter-desktop/go-flutter

I'm seeing an issue that I've seen before. I know how it can be fixed, but I'm not succeeding in applying the fix to this project.

In flutter-desktop-embedding I encountered an error that was caused by improper resolving of GL functions. The Flutter>Skia>GL rendering would assume the wrong GL context and resolved the wrong procs, ending up in a bunch of errors. Providing flutter with a glfw proc resolver fixed the issue. This occurs on machines with multiple video cards (e.g.: intel graphics as part of the CPU and an nvidia card for when there's some actual GPU power required).

This issue was fixed in flutter-desktop-embedding by the following PR: https://github.com/google/flutter-desktop-embedding/pull/184

I really like Go, have been working with it since before Go v 1.0. So obviously I wanted to try this project as well. I tried to rework the fix over for this project, but ran into a few issues.

First of all, the go-gl/glfw project doesn't expose glfwGetProcAddress.
There's an open issue about it: https://github.com/go-gl/glfw/issues/234

I tried to start patching this by using glfw directly. Not as a permanent solution, but just to try out the fix and create a use-case example for go-gl/glfw to expose glfwGetProcAddress. ~However, it's not working, compile warning on the proxy function I made, I'm probably doing something wrong in C land.
The changes I made are visible here: https://github.com/Drakirus/go-flutter-desktop-embedder/compare/master...GeertJohan:feature/add-gl-proc-resolver~

~The compile error on my feature branch:~

~# github.com/Drakirus/go-flutter-desktop-embedder/flutter
/tmp/go-build300793477/b036/_x004.o: In function _cgo_b8b7151b1d3c_Cfunc_glfwGetProcAddress': /tmp/go-build/cgo-gcc-prolog:61: undefined reference toglfwGetProcAddress'
/tmp/go-build300793477/b036/_x005.o: In function runFlutter': ../../flutter/flutter_helper.c:31: undefined reference toproxy_gl_proc_resolver'
collect2: error: ld returned 1 exit status~

Edit: The quick'n'dirty fix works now. See comment below.

Note that I had to copy over some of the new fields and structs of the embedder API to get access to the gl_proc_resolver parameter.

I hope we may be able to fix this, preferably by having glfwGetProcAddress exposed from the go-gl/glfw package. Any help is welcome.

Flutter version

Flutter 1.2.1 • channel dev • https://github.com/flutter/flutter.git
Framework • revision 8661d8aecd (2 days ago) • 2019-02-14 19:19:53 -0800
Engine • revision 3757390fa4
Tools • Dart 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

Does the prebuilt and portable version works ?

  • No

Steps to Reproduce

  1. Build following the instructions
  2. Run the binary (./main)

[WARNING:flutter/shell/platform/embedder/embedder.cc(312)] FlutterProjectArgs.main_path is deprecated and should be set null.
[WARNING:flutter/shell/platform/embedder/embedder.cc(317)] FlutterProjectArgs.packages_path is deprecated and should be set null.
[ERROR:flutter/shell/platform/embedder/embedder_surface_gl.cc(89)] Could not create a resource context for async texture uploads. Expect degraded performance. Set a valid make_resource_current callback on FlutterOpenGLRendererConfig.
[ERROR:flutter/shell/gpu/gpu_surface_gl.cc(85)] Failed to setup Skia Gr context.
[ERROR:flutter/shell/platform/embedder/embedder_surface_gl.cc(89)] Could not create a resource context for async texture uploads. Expect degraded performance. Set a valid make_resource_current callback on FlutterOpenGLRendererConfig.
flutter: Observatory listening on http://127.0.0.1:50300/
2019/02/16 16:28:59 PlatformError: GLX: Failed to make context current
[1] 18962 segmentation fault (core dumped) ./main

GLFW embedder

Most helpful comment

This issue is my top priority.
I won't be available until next week. I will get back to it later.

All 4 comments

This issue is my top priority.
I won't be available until next week. I will get back to it later.

I managed to get the fix working using GLFW directly. This demonstrates that the issue is in fact the same as the one I had with flutter-desktop-embedding, and that the solution is to provide the flutter engine with the gl_proc_resolver.
I kept the solution in C, because wiring the function call into and back out of Go didn't seem to make much sense here.

https://github.com/Drakirus/go-flutter-desktop-embedder/compare/master...GeertJohan:feature/add-gl-proc-resolver

It's not so nice that this makes the flutter Go package dependent on GLFW.h and libglfw. I believe that should remain the responsibility of go-gl/glfw.

Yes, it should remain the responsibility of go-gl/glfw.
Waiting for go-gl/glfw#234 to be resolved.

I have added two more iterations.

I've created a PR at go-gl/glfw which makes the last iteration compile. When it's merged into master, I'll cleanup commit history and create a PR here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

inaxium picture inaxium  Â·  4Comments

Fireprufe15 picture Fireprufe15  Â·  6Comments

monkeyWie picture monkeyWie  Â·  7Comments

atresnjo picture atresnjo  Â·  4Comments

pchampio picture pchampio  Â·  3Comments