"pixi.js: WebGL not supported" – suppressing console noise while keeping critical alerts
19K reputation · 16 Oct 2022, 09:12 UTC
When initializing PixiJS in a browser that lacks WebGL support, the library throws the error pixi.js: WebGL not supported and logs it to the console immediately. In production builds this message is useful, but in development environments it can flood the console, making it hard to spot genuine runtime problems such as missing assets or internal API misuse.
The goal is to keep the WebGL‑unsupported notice visible (so developers are aware of the rendering limitation) while suppressing or filtering out the repetitive console logs that PixiJS emits for other non‑critical conditions, such as the default PIXI.Loader error event logging for each missing texture.
Constraints include:
- Maintaining the ability to catch and react to critical loader errors.
- Preserving the default behaviour for WebGL detection without introducing a custom polyfill.
- Ensuring compatibility across PixiJS v6 and v7 where the error handling APIs differ slightly.
Unresolved questions:
- Does setting
PIXI.settings.STRICT = trueautomatically suppress console logs for non‑critical errors, or does it only change the behaviour for internal exceptions? - Is there a documented way to override
PIXI.utils.erroror the loader’serrorevent to filter specific messages while still allowing critical alerts to surface? - What best‑practice pattern exists for suppressing the
pixi.js: WebGL not supportedmessage in a controlled manner without affecting other error notifications?