Skip to content

PlatformError: GLX: Failed to make context current #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
GeertJohan opened this issue Feb 16, 2019 · 4 comments
Closed

PlatformError: GLX: Failed to make context current #68

GeertJohan opened this issue Feb 16, 2019 · 4 comments
Labels
embedder Issue concerns the embedder package GLFW

Comments

@GeertJohan
Copy link
Member

GeertJohan commented Feb 16, 2019

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: google/flutter-desktop-embedding#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: go-gl/glfw#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: 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 to glfwGetProcAddress'
/tmp/go-build300793477/b036/_x005.o: In function runFlutter': ../../flutter/flutter_helper.c:31: undefined reference to proxy_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

@GeertJohan GeertJohan changed the title Skia quit becuase of invalid PlatformError: GLX: Failed to make context current Feb 16, 2019
@pchampio
Copy link
Member

pchampio commented Feb 16, 2019

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

@GeertJohan
Copy link
Member Author

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.

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.

@pchampio
Copy link
Member

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

@GeertJohan
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embedder Issue concerns the embedder package GLFW
Development

No branches or pull requests

2 participants