mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 08:59:40 +02:00
feat(terminal): add WebGL renderer toggle in settings
Adds a 'WebGL Renderer' toggle to Settings > Appearance (desktop). WebGL stays on by default; users can turn it off to force the DOM renderer when they hit GPU glitches, without needing the ?nowebgl URL param. Explicit opt-in (or ?webgl=force) clears a stale auto-fallback marker. Mobile skip and the long-task auto-fallback safety net are unchanged. The device/param/sticky/pref interaction is factored into a pure, unit-tested shouldSkipWebGL() helper in constants.js.
This commit is contained in:
@@ -246,9 +246,6 @@ Object.assign(CodemanApp.prototype, {
|
||||
// Lazy-loaded: script downloaded only on desktop (saves 244KB on mobile).
|
||||
this._webglAddon = null;
|
||||
const _params = new URLSearchParams(location.search);
|
||||
if (_params.get('webgl') === 'force') {
|
||||
try { localStorage.removeItem('codeman-webgl-disabled'); } catch {}
|
||||
}
|
||||
const _stickyDisabled = (() => {
|
||||
try {
|
||||
const raw = localStorage.getItem('codeman-webgl-disabled');
|
||||
@@ -263,11 +260,23 @@ Object.assign(CodemanApp.prototype, {
|
||||
return true;
|
||||
} catch { return false; }
|
||||
})();
|
||||
const skipWebGL =
|
||||
MobileDetection.getDeviceType() !== 'desktop' ||
|
||||
_params.has('nowebgl') ||
|
||||
_stickyDisabled;
|
||||
if (_stickyDisabled) {
|
||||
// User's "WebGL Renderer" toggle (Settings > Appearance). undefined = untouched
|
||||
// (desktop default on); false = explicit opt-out; true = explicit opt-in.
|
||||
const _webglSettings = this.loadAppSettingsFromStorage();
|
||||
const _webglDefaults = this.getDefaultSettings();
|
||||
const _webglPref = _webglSettings.webglRendererEnabled ?? _webglDefaults.webglRendererEnabled;
|
||||
const { skip: skipWebGL, clearSticky: _clearWebglSticky } = shouldSkipWebGL({
|
||||
deviceType: MobileDetection.getDeviceType(),
|
||||
noWebglParam: _params.has('nowebgl'),
|
||||
forceParam: _params.get('webgl') === 'force',
|
||||
stickyDisabled: _stickyDisabled,
|
||||
userPrefEnabled: _webglPref,
|
||||
});
|
||||
// Explicit opt-in (toggle ON) or ?webgl=force retires a stale auto-fallback marker.
|
||||
if (_clearWebglSticky) {
|
||||
try { localStorage.removeItem('codeman-webgl-disabled'); } catch {}
|
||||
}
|
||||
if (skipWebGL && _stickyDisabled) {
|
||||
console.log('[CRASH-DIAG] WebGL sticky-disabled from prior stalls — DOM renderer in use. Re-enable: ?webgl=force');
|
||||
}
|
||||
if (!skipWebGL) {
|
||||
|
||||
Reference in New Issue
Block a user