#Tauri WebView doesn't use discrete GPU for WebGL

2 messages · Page 1 of 1 (latest)

north current
#

I have a WebGL context, created with powerPreference option:

const gl = canvas.getContext('webgl2', {
  powerPreference: 'high-performance',
});

in Safari, after disabling "WebGL via Metal" experimental feature, it switches to discrete GPU, but in Tauri this isn't the case
I thought Safari tells WebKit somehow to disable Metal, so looked for some docs:
https://trac.webkit.org/wiki/FeatureFlags
https://trac.webkit.org/wiki/EnvironmentVariables
but there's no such thing there

slender cove
#

I'm not an expert on WebGL or WebKit's use of it. The WebGL specification (which WebGL 2.0 inherits from) describes powerPreference as "only a hint and a WebGL implementation may choose to ignore it" (https://registry.khronos.org/webgl/specs/latest/1.0/#5.2.1). If I'm reading the inferences of the patch for WebKit Bug 229267 (https://bugs.webkit.org/show_bug.cgi?id=229267) correctly, it sounds like WebKit doesn't directly concern itself too much with webgl2 and only concentrates on webgl; this might be related to their 2021 switch to Google's ANGLE (https://trac.webkit.org/wiki/AngleforWebGL). It's quite possible that Safari invokes a flag that is not documented in WebKit but in ANGLE. After taking a brief look at ANGLE, I found EGL_ANGLE_power_preference.txt (https://github.com/google/angle/blob/251ba5cb119ff2fed0e861cbc9b096c45004c1fa/extensions/EGL_ANGLE_power_preference.txt) which states that "[t]he containing application must set the NSSupportsAutomaticGraphicsSwitching attribute to true in its Info.plist in order for this extension to operate as advertised."