Skip to content

[BUG] Firefox WebGL warning: AllowWebgl2:false restricts context creation on this system #11566

Closed

Description

Context:

  • Playwright Version: 1.18.0
  • Operating System: Docker on Windows
  • Node.js version: 16.13.2
  • Browser: Firefox
  • Extra: [any specific details about your environment]

Code Snippet
Dockerfile:

FROM mcr.microsoft.com/playwright:focal

WORKDIR /app
COPY . ./
RUN npm install 
EXPOSE 8080
# runs ts-node src/index.ts
CMD    ["npm", "run", "production"]

src/index.ts

import { firefox } from "playwright";
const browser = await firefox.launch({headless: true});
const page = await browser.newPage({ viewport: { width: 1920, height: 1080 } });
page.on("console", (message) => {
    console.log("----->", message.text());
});
await page.goto('http://localhost:8080/serveRenderer/');
await page.dispatchEvent("#unityLoaded", "click");
console.log("Renderer loaded!");

Describe the bug
Hi, first of all, thanks for this great package. I use it quite often. However, there's one bug with the firefox browser. As you can see in my Dockerfile, I'm using your image as the base and executing a TypeScript script. This loads a page from a webserver which contains some WebGL stuff (in particular a Unity WebGL Export, but that shouldn't matter).

When I run the script with firefox as the browser to use, I get the following error:
(all lines starting with "---->" come from the browser's console and are printed via the on "console" event (see above))

# npm run production

> mpx-device-renderer@1.0.0 production
> ts-node src/index.ts

Starting websocket server...
Connecting to storage server...
Starting headless browser...
Starting express server...
Server started on port 8080!
Loading 3D Renderer...
connection
-----> ws connection opened!
-----> [JavaScript Warning: "WebGL warning: <Create>: AllowWebgl2:false restricts context creation on this system." {file: "http://localhost:8080/serveRenderer/Build/buildTest.loader.js" line: 1}]
-----> [JavaScript Warning: "Failed to create WebGL context: WebGL creation failed:
* AllowWebgl2:false restricts context creation on this system. ()" {file: "http://localhost:8080/serveRenderer/Build/buildTest.loader.js" line: 1}]
-----> [JavaScript Warning: "WebGL warning: <Create>: WebglAllowWindowsNativeGl:false restricts context creation on this system." {file: "http://localhost:8080/serveRenderer/Build/buildTest.loader.js" line: 1}]
-----> [JavaScript Warning: "Failed to create WebGL context: WebGL creation failed:
* WebglAllowWindowsNativeGl:false restricts context creation on this system. ()
* Exhausted GL driver options. (FEATURE_FAILURE_WEBGL_EXHAUSTED_DRIVERS)" {file: "http://localhost:8080/serveRenderer/Build/buildTest.loader.js" line: 1}]
/app/src/index.ts:63
                res.set("Content-Type", "application/wasm");
                      ^
page.dispatchEvent: Timeout 30000ms exceeded.

(the timeout is expected, it comes from the #unityLoaded element not being created as the index.html creates this element dynamically once the webgl context on the canvas has initialized completely).

With chromium, however, it works just fine:

# npm run production

> mpx-device-renderer@1.0.0 production
> ts-node src/index.ts

Starting websocket server...
Connecting to storage server...
Starting headless browser...
Starting express server...
Server started on port 8080!
Loading 3D Renderer...
connection
-----> ws connection opened!
-----> navigator.mediaDevices support available
-----> [UnityCache] 'http://localhost:8080/serveRenderer/Build/buildTest.data.gz' successfully downloaded and stored in the indexedDB cache
-----> [UnityMemory] Configuration Parameters - Can be set up in boot.config

----->     "memorysetup-temp-allocator-size-nav-mesh-worker=65536"

----->     "memorysetup-temp-allocator-size-audio-worker=65536"

----->     "memorysetup-temp-allocator-size-cloud-worker=32768"

----->     "memorysetup-temp-allocator-size-background-worker=32768"

----->     "memorysetup-bucket-allocator-granularity=16"

----->     "memorysetup-bucket-allocator-bucket-count=8"

----->     "memorysetup-bucket-allocator-block-size=4194304"

----->     "memorysetup-bucket-allocator-block-count=1"

----->     "memorysetup-main-allocator-block-size=16777216"

----->     "memorysetup-thread-allocator-block-size=16777216"

----->     "memorysetup-gfx-main-allocator-block-size=16777216"

----->     "memorysetup-gfx-thread-allocator-block-size=16777216"

----->     "memorysetup-cache-allocator-block-size=4194304"

----->     "memorysetup-typetree-allocator-block-size=2097152"

----->     "memorysetup-profiler-bucket-allocator-granularity=16"

----->     "memorysetup-profiler-bucket-allocator-bucket-count=8"

----->     "memorysetup-profiler-bucket-allocator-block-size=4194304"

----->     "memorysetup-profiler-bucket-allocator-block-count=1"

----->     "memorysetup-profiler-allocator-block-size=16777216"

----->     "memorysetup-profiler-editor-allocator-block-size=1048576"

----->     "memorysetup-temp-allocator-size-main=4194304"

----->     "memorysetup-job-temp-allocator-block-size=2097152"

----->     "memorysetup-job-temp-allocator-block-size-background=1048576"

----->     "memorysetup-job-temp-allocator-reduction-small-platforms=262144"

-----> Loading player data from data.unity3d

-----> Initialize engine version: 2021.2.7f1 (6bd9e232123f)

-----> [Subsystems] Discovering subsystems at path UnitySubsystems

-----> Creating WebGL 2.0 context.
-----> Renderer: WebKit WebGL

-----> Vendor:   WebKit

-----> Version:  OpenGL ES 3.0 (WebGL 2.0 (OpenGL ES 3.0 Chromium))

-----> GLES:     3

----->  EXT_color_buffer_float EXT_color_buffer_half_float EXT_float_blend EXT_texture_compression_bptc EXT_texture_compression_rgtc EXT_texture_filter_anisotropic KHR_parallel_shader_compile OES_texture_float_linear WEBGL_compressed_texture_astc WEBGL_compressed_texture_etc WEBGL_compressed_texture_etc1 WEBGL_compressed_texture_s3tc WEBGL_compressed_texture_s3tc_srgb WEBGL_debug_renderer_info WEBGL_lose_context WEBGL_multi_draw OVR_multiview2 GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_EXT_float_blend GL_EXT_texture_compression_bptc GL_EXT_texture_compression_rgtc GL_EXT_texture_filter_anisotropic GL_KHR_parallel_shader_compile GL_OES_texture_float_linear GL_WEBGL_compressed_texture_astc GL_WEBGL_compressed_texture_etc GL_WEBGL_compressed_texture_etc1 GL_WEBGL_compressed_texture_s3tc GL_WEBGL_compressed_texture_s3tc_srgb GL_WEBGL_debug_renderer_info GL_WEBGL_lose_context GL_WEBGL_multi_draw GL_OVR_multiview2

-----> OPENGL LOG: Creating OpenGL ES 3.0 graphics device ; Context level  <OpenGL ES 3.0> ; Context handle 1

-----> Input Manager initialize...

-----> UnloadTime: 0.500000 ms

-----> [.WebGL-0x35a21c321500]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
-----> [.WebGL-0x35a21c321500]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
-----> [.WebGL-0x35a21c321500]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
-----> [.WebGL-0x35a21c321500]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels (this message will no longer repeat)
Renderer loaded!

Activity

  1. mxschmitt commented on Jan 23, 2022

    @mxschmitt
    Contributor

    Would it be possible that you can provide us your localhost server or some small demo / repro of it?

  2. hrueger commented on Jan 23, 2022

    @hrueger
    Author

    Sure, I'll work on it tomorrow.

  3. hrueger commented on Jan 24, 2022

    @hrueger
    Author

    Hi Max Schmitt (@mxschmitt),
    I've created the following repo for you: https://github.com/hrueger/playwright-issue-11566
    Instructions are in the README file.

    Hope that helps! If there's anything missing, just let me know.

  4. hrueger commented on Feb 1, 2022

    @hrueger
    Author

    I did some more research / debugging.
    If I add "webgl.force-enabled": true, to the firefoxUserPrefs config option of the firefox.launch()` method, the error message changes. I now get:

    -----> [JavaScript Warning: "Failed to create WebGL context: WebGL creation failed: 
    * tryNativeGL ()
    * Exhausted GL driver options. (FEATURE_FAILURE_WEBGL_EXHAUSTED_DRIVERS)" {file: "http://localhost:8080/serveRenderer/Build/buildTest.loader.js" line: 1}]
    
    -----> [JavaScript Warning: "Failed to create WebGL context: WebGL creation failed: 
    * tryNativeGL ()
    * Exhausted GL driver options. (FEATURE_FAILURE_WEBGL_EXHAUSTED_DRIVERS)" {file: "http://localhost:8080/serveRenderer/Build/buildTest.loader.js" line: 1}]
    

    Setting "gfx.webrender.all": true, "gfx.webrender.enabled": true, "layers.acceleration.force-enabled": true as suggested here doesn't help.

  5. yury-s commented on Feb 1, 2022

    @yury-s
    Member

    This upstream bug sounds related.

  6. hrueger commented on Feb 2, 2022

    @hrueger
    Author

    Does that mean it needs to be fixed in firefox itself? I can't find a bug with that error message in bugzilla...

    This bug is really the only thing preventing us from using our app in production, so if there's anything more that can be done to help you fix this, just let me know!

  7. yury-s commented on Feb 2, 2022

    @yury-s
    Member

    Does that mean it needs to be fixed in firefox itself?

    Yes, it's upstream code in Firefox, you can try tweaking the setting and see if that helps, my hunch is that in headless mode/under docker they might not be able to use hardware accelerated mode without which some of the features the app uses don't work.

  8. hrueger commented on Feb 5, 2022

    @hrueger
    Author

    As we really need this app in production in the next days, I migrated from using firefox to chromium.
    If you want, we can keep that open, as the issue is not really resolved, but we can also close it.

  9. hrueger commented on Feb 5, 2022

    @hrueger
    Author

    Just for reference: I also spent a few more hours trying out different config flags I found in some forum posts, but none of those changed anything.

  10. pavelfeldman commented on Oct 20, 2022

    @pavelfeldman
    Member

    Why was this issue closed?

    We are prioritizing the bugs based on the upvotes, recency and our ability to act. It looks like this issue only has a handful of upvotes, has not been touched recently and/or we lack sufficient feedback to act on it. We are closing issues like this one to keep our bug database maintainable. Please feel free to open a new issue and link this one to it if you think this is a mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions