Fix Adreno GPU crashes from symbol UBO dynamic indexing#13653
Closed
navidemad wants to merge 5 commits intomapbox:mainfrom
Closed
Fix Adreno GPU crashes from symbol UBO dynamic indexing#13653navidemad wants to merge 5 commits intomapbox:mainfrom
navidemad wants to merge 5 commits intomapbox:mainfrom
Conversation
Disable symbol UBO batching on Adreno GPUs (Qualcomm, used in Pixel 7/8/8A/9a) where GLSL ES 3.00 dynamic indexing into UBO arrays causes GPU faults and page crashes during zoom/pan. Also fix readFloat/readUint in the symbol shader to use the existing Adreno-safe swizzle helpers, correct a stale getMaxFeatureCount default, and guard against zero-division in the cutoff formula. Fixes mapbox#13651 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Hey, @navidemad 👋 Thanks for your contribution to Mapbox GL JS! Important: This repository does not accept direct merges. All changes go through our internal review process. What happens next:
Please respond to any review comments on this PR. For more details, see CONTRIBUTING.md. |
Add unit tests for the two code paths that lacked coverage: - context_gpu_flags.test.ts: verify disableSymbolUBO is false by default and true when forceDisableSymbolUBO option is set. - cutoff.test.ts: verify getCutoffParams returns finite values when zRange is zero or negative, and exercises early-exit paths (zero fade range, terrain active, low pitch). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
context_gpu_flags.test.ts:
- Add renderer-based detection tests: Adreno → disabled, PowerVR → disabled,
Apple M2 → enabled. Uses getExtension/getParameter interception to inject
fake WEBGL_debug_renderer_info strings deterministically.
- Guard createContext() with explicit null check on getContext('webgl2').
cutoff.test.ts:
- Add invariant assertions for active cutoff: all 4 params finite,
relativeCutoffFadeDistance <= relativeCutoffDistance, both non-negative.
- Keep existing zero/negative zRange and early-exit coverage.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove host-dependent "disabled by default on standard GPUs" test that would fail on Adreno/PowerVR machines. All four remaining tests use createGLWithRenderer() to inject a controlled renderer string. - Wire forceDisableSymbolUBO through the render test infrastructure (one-line addition in utils.ts, matching the existing forceManualRenderingForInstanceIDShaders pattern). - Add text-color/property-function-no-symbol-ubo render test: exercises data-driven symbol rendering with UBO disabled, verifying the pragma fallback path renders correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- context_gpu_flags.test.ts: add createGLWithoutRendererInfo() helper that makes WEBGL_debug_renderer_info return null. Two new tests verify disableSymbolUBO is falsy without the extension and that forceDisableSymbolUBO still overrides it. - text-halo-color/property-function-no-symbol-ubo: new render fixture exercising data-driven text-halo-color with UBO disabled. Covers halo_np_color (UBO property index 1), complementing the existing text-color fixture (fill_np_color, index 0). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Hey @navidemad, thanks for the PR! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #13651 — v3.21.0 crashes on Android Pixel devices (Pixel 7, 8, 8A, 9a) during zoom/pan due to Adreno GPU incompatibility with the new symbol UBO feature.
Root cause: Adreno GPUs (like PowerVR, already disabled in
9880b06b) do not correctly handle dynamic (non-uniform) indexing into UBO arrays — this is technically undefined behavior in GLSL ES 3.00. The symbol shader also had inconsistent Adreno workarounds:uvec4At/vec4Atused safe explicit swizzles, butreadFloat/readUintused direct bracket indexing that fails on affected Adreno drivers.Changes
src/gl/context.ts— Disable symbol UBO batching on Adreno GPUs, matching the existing PowerVR treatment.src/shaders/symbol.vertex.glsl— Replace directslot[index]bracket indexing inreadFloat/readUintwith the existing Adreno-safevec4At/uvec4Athelpers.src/data/bucket/symbol_properties_ubo.ts— Fix stale default parameter ingetMaxFeatureCount(was4096 - 12 = 4084, should be4096after the sizing fix ine56c5673).src/render/cutoff.ts— GuardzRangedivision against near-zero values on mobile viewports.CHANGELOG.md— Added changelog entry per contributing guidelines.test/unit/gl/context_gpu_flags.test.ts— New: regression tests for thedisableSymbolUBOflag (default behavior andforceDisableSymbolUBOoverride).test/unit/render/cutoff.test.ts— New: regression tests forgetCutoffParamscovering the zero/negativezRangeguard and all early-exit paths.test/unit/data/symbol_property_binder_ubo.test.ts— Updated expected value forgetMaxFeatureCountdefault parameter fix.Test plan
npm run tsc)symbol_property_binder_ubo.test.ts— all 35 tests passcontext_gpu_flags.test.ts— 2 new tests passcutoff.test.ts— 6 new tests pass🤖 Generated with Claude Code