Skip to content

Conversation

@sensei-hacker
Copy link
Member

Summary

Adds automatic fallback from hardware to software WebGL rendering with graceful degradation when WebGL is completely unavailable.

⚠️ Testing Required

This PR needs testing in Windows VM after CI builds complete:

  • Test with GPU drivers missing/outdated
  • Test in Remote Desktop / VNC session
  • Test with hardware acceleration disabled in Options
  • Verify fallback messages appear correctly
  • Verify no crashes occur

Problem

The configurator had WebGL detection code but crashed when WebGL was unavailable:

  • When renderer.getContext('webgl') failed, renderer stayed undefined
  • Code then tried to call renderer.setSize()crash: Cannot read property 'setSize' of undefined
  • The existing "fallback" model was never used because the app crashed before loading it

Solution

Implemented a 3-tier progressive fallback:

  1. Tier 1: Try hardware-accelerated WebGL (best performance)
  2. Tier 2: Try software-rendered WebGL with failIfMajorPerformanceCaveat: false (slower but compatible)
  3. Tier 3: Show user-friendly message and provide no-op functions (graceful degradation)

Changes

  • Add tryCreateWebGLContext() helper with 3-tier fallback
  • Try hardware WebGL, then software WebGL, then graceful disable
  • Show user-friendly error messages when 3D unavailable with actionable troubleshooting steps
  • Provide no-op render3D() and resize3D() functions to prevent crashes
  • Add console logging for WebGL rendering method detection

Testing Completed

Linux testing:

  • ✅ Normal operation (hardware WebGL available) - PASSED
  • ✅ WebGL completely unavailable (forced fail) - PASSED, shows fallback message

Benefits

  • Prevents crashes when WebGL unavailable in Setup and Magnetometer tabs
  • Improves UX for users with GPU driver issues
  • Better support for VM environments and Remote Desktop
  • Clear guidance for users on how to resolve issues

Files Modified

  • tabs/setup.js: Robust WebGL detection for 3D aircraft model
  • tabs/magnetometer.js: Robust WebGL detection for compass visualization

Add automatic fallback from hardware to software WebGL rendering
with graceful degradation when WebGL is completely unavailable.

Changes:
- Add tryCreateWebGLContext() helper with 3-tier fallback
- Try hardware WebGL, then software WebGL, then graceful disable
- Show user-friendly messages when 3D unavailable
- Provide no-op functions to prevent crashes
- Add console logging for WebGL rendering method

Fixes crashes when WebGL unavailable in Setup and Magnetometer tabs.
Improves UX for users with GPU driver issues or running in VMs.

Files modified:
- tabs/setup.js: Robust WebGL detection
- tabs/magnetometer.js: Robust WebGL detection
@Jetrell
Copy link
Collaborator

Jetrell commented Dec 31, 2025

I tested it on an older laptop with older drivers.
With 3D acceleration disabled in the application options. It works the same as it does with the present RC3 release. Any extra load placed on the graphic hardware, above what was there before the ESM updates prior to RC1, is still there with this build.

When 3D acceleration disable is unchecked. This is the effect.

3D acceleration disabled unchecked in #2512

However the configurator doesn't sit there is an internal "waiting for data" state, like it did before this PR. If 3D acceleration disabled wasn't checked in the application options.

I forwarded the build link to some others that had asked about this issue last month. I'll see what they have to say when they get back to me.

@sensei-hacker
Copy link
Member Author

Thanks, Jetrell! The screenshot shows the desired behavior if WebGL isn't available (via hardware acceleration or software emulation).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants