Closed jmschrack closed 2 years ago
chrome://gpu logs:
Graphics Feature Status
Canvas: Hardware accelerated
Flash: Hardware accelerated
Flash Stage3D: Hardware accelerated
Flash Stage3D Baseline profile: Hardware accelerated
Compositing: Hardware accelerated
Multiple Raster Threads: Enabled
Out-of-process Rasterization: Disabled
OpenGL: Enabled
Hardware Protected Video Decode: Hardware accelerated
Rasterization: Hardware accelerated
Skia Renderer: Disabled
Video Decode: Hardware accelerated
Viz Display Compositor: Enabled
WebGL: Hardware accelerated
WebGL2: Hardware accelerated
Driver Bug Workarounds
clear_uniforms_before_first_program_use
decode_encode_srgb_for_generatemipmap
disable_discard_framebuffer
exit_on_context_lost
force_cube_complete
msaa_is_slow
scalarize_vec_and_mat_constructor_args
disabled_extension_GL_KHR_blend_equation_advanced
disabled_extension_GL_KHR_blend_equation_advanced_coherent
Problems Detected
Some drivers are unable to reset the D3D device in the GPU process sandbox
Applied Workarounds: exit_on_context_lost
Clear uniforms before first program use on all platforms: 124764, 349137
Applied Workarounds: clear_uniforms_before_first_program_use
Always rewrite vec/mat constructors to be consistent: 398694
Applied Workarounds: scalarize_vec_and_mat_constructor_args
ANGLE crash on glReadPixels from incomplete cube map texture: 518889
Applied Workarounds: force_cube_complete
On Intel GPUs MSAA performance is not acceptable for GPU rasterization: 527565
Applied Workarounds: msaa_is_slow
Framebuffer discarding can hurt performance on non-tilers: 570897
Applied Workarounds: disable_discard_framebuffer
Disable KHR_blend_equation_advanced until cc shaders are updated: 661715
Applied Workarounds: disable(GL_KHR_blend_equation_advanced), disable(GL_KHR_blend_equation_advanced_coherent)
Decode and Encode before generateMipmap for srgb format textures on Windows: 634519
Applied Workarounds: decode_encode_srgb_for_generatemipmap
So it looks like the WebGL context is never getting restored. To confirm this, i downloaded the source from the 4.0.0 branch, and I added these observables in editor.tsx right after the engine is created.
this.engine.onContextLostObservable.add(() => {
alert("WHOOPS LOST CONTEXT!");
});
this.engine.onContextRestoredObservable.add(() => {
alert("GOT CONTEXT AGAIN!");
});
Obviously I get a pop-up on losing the context shortly after loading the scene. But I never get a pop-up for context Restored, even if I let it sit there for a while.
On a hunch, I set: disableWebGL2Support: true,
in the engine constructor, with this I never lose the WebGL context.
Unfortunately, I get a ton of other errors related to missing features this way.
I figured it out! It's a problem with the OEM Intel UHD Graphics driver and Window's "Graphics Performance Setting" I have found two possible solutions, and verified that both of these work on two different laptops.
Install the Generic Intel DCH graphics driver (I recommend using the Driver Support Assistant to do this.) Read the caveat, but in short: your default drivers are usually customized by the manufacturer, but this generic driver is not. Obviously you run the risk of screwing something up.
Hi @jmschrack !
Thanks a lot for all these investigations! This problem raised some problems in the Editor like it doesn't take care of WebGL 1 etc.
Do you think the Editor must support WebGL 1 ? It is said that WebGL 2 is supported everywhere except on iOS (for the moment).
I don't think the editor should support WebGL1.
The core problem here is a Window's Intel driver bug. I think the better solution would be to hook into the onContextLostObservable event, and display a error message if they are on Windows and the Intel graphics driver is detected.
Something like:
this.engine.onContextLostObservable.add(() => {
//this is a windows only bug and only occurs on Intel UHD Graphics chips.
if(process.platform === "win32"){
var intelPattern= /Intel.*Graphics/g;
const exec=require("child_process");
const os = require("os");
//get a list of all the GPU drivers on the system
exec("wmic path win32_VideoController get name", (error,stdout,stderr) => {
if(error){
console.error(stderr);
}
//filter for Intel Graphics
if(intelPattern.exec(stdout)){
/*
The windows command prompt starts with "name" on the first line, and 2 trailing EOL.
So we subtract 3 to determine the number of GPU drivers.
If there is more than 1 driver: Windows is (probably) setting the app to Graphics Power Saver mode,
which uses the Intel chip instead of the discrete GPU. This can be fixed by going to
settings>Graphics Settings and setting BabylonJS Editor to "High Performance mode"
Otherwise, they only have the Intel chip, and the only solution is to update using the
Generic Intel DCH Graphics driver.
*/
if(stdout.split(os.EOL).length-3>1){
alert("WebGL Context lost! We detected multiple video drivers including 'Intel Graphics'. If you continue to see this, Windows may be putting the Editor into Power Save Mode."+
"\n Go to Settings>Graphics Settings and set BabylonJS Editor to High Performance Mode. ");
}else{
alert("WebGL Context lost! We detected you are using Intel Graphics. If this continues to happen, you may need to manually update the Generic Intel DCH Graphics driver.")
}
}
});
}
});
I'm not super knowledgeable about electron. I assume there are better alternatives for pop-up boxes other than the "alert" function. I also don't know how often context gets lost and then regained normally, so if you go this route, I'd recommend some way of allowing the user to "Ignore future errors" just in case.
I did some digging, and unfortunately there is currently no way to determine if Windows has set your app to "Power Saver Mode" or not, so we just have to assume if the context keeps disappearing and it's a Intel Graphics chip, then it's this bug.
@jmschrack you are awesome, I'm trying it out Also, I have added your solutions in the troubleshooting documenation of the editor.
Thanks a lot !
Fresh install. v4.0.0-rc3
When I open up a project (or create a new one), the scene view loads for a moment, and then the BabylonJS logo covers the entire screen. When the editor comes back, the preview is blank.
"WebGL Context lost" can be seen in the Console window.
Here's the logs from opening up the developer console.