Skip to content

[Due for payment 2026-08-19] [Sentry: APP-7MV] Web WebGL context creation failure on /search and /home (resurfaced on 9.4.43+) #97104

Closed

Description

@mountiny

Sentry

https://expensify.sentry.io/issues/APP-7MV

Impact (snapshot at filing)

  • Users (total since first seen): 560
  • Events: 8950
  • Users (last 7d): 10
  • First seen: 2026-03-15
  • Last seen: ongoing (2026-07-26)
  • Platform: web
  • App version(s): 9.4.43-1, 9.4.41-4 (resurfaced on latest production)
  • Affected route(s): /search, /home (previously /home only in prior tracker)
  • Mechanism: auto.browser.browserapierrors.setTimeout

Stack trace (top frames)

failed to create webgl context: err 0
Error: failed to create webgl context: err 0
@sentry/browser helpers → captureException
Search_Root view

Suspected cause

WebGL context creation fails on low-memory or GPU-constrained browsers while Search or Home renders WebGL-dependent UI. Crash resurfaced on 9.4.43+ after prior fix was paid/closed.

Reproduction

Unknown — see Sentry events. Prior tracker focused on /home; new events also on /search.

Related

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit

Activity

  1. mountiny commented on Jul 27, 2026

    @mountiny
    ContributorAuthor

    @wildan-m — please self-assign; automated assign failed (API could not add you). Carried forward from prior tracker #93834.

  2. wildan-m commented on Jul 27, 2026

    @wildan-m
    Contributor

    @mountiny how to do that? self assign

  3. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 27, 2026
  4. mountiny commented on Jul 27, 2026

    @mountiny
    ContributorAuthor

    Added you, seems like this events is still happening for users, can you take a look please?

  5. MelvinBot commented on Jul 27, 2026

    @MelvinBot
    Contributor

    Proposal

    🤖 Automated analysis — confidence: High for the root cause, Medium for the exact fix (the failure is environmental, so the goal is graceful degradation, not "making WebGL work"). Same Sentry ID as the paid/closed #93834; PR #94937 fixed one path but left the gap that resurfaced this.

    What is the root cause of that problem?

    Charts on /home and /search are drawn with Skia/CanvasKit, which asks the browser for a WebGL2 context and never falls back to software. When the browser can't hand one out — hardware acceleration off, GPU blocklisted, memory pressure, or the per-page WebGL context limit exhausted — CanvasKit throws failed to create webgl context: err 0. It throws from an async draw tick (requestAnimationFrame/setTimeout), so no try/catch and no React ErrorBoundary can catch it → it lands in Sentry (APP-7MV, auto.browser.browserapierrors.setTimeout).

    PR #94937 added a pre-mount WebGL2 probe (SkiaWebChart/index.tsx:63) that shows an "Unable to display chart" empty state when WebGL2 is unavailable. That fixed the always-broken-GPU case, but the crash resurfaced because the probe can't see the failure that's actually happening now:

    • The probe reuses one long-lived context and biases toward "supported" (isSkiaWebSupported.ts:8-10, returns true on a lost context at :35-36 and on any exception at :39-40). That softening was intentional — to avoid hiding charts from capable mobile devices — but it means the probe passes while CanvasKit's separate, per-mount context creation can still fail.
    • This is exactly the /search regression: /search mounts/re-mounts several Skia canvases (Bar, Line, Pie across insight tabs, plus Home's chart may be alive) and can exhaust the browser's per-page context cap (~16 in Chrome). The single-context probe never trips this cap, so it green-lights a mount that then throws.
    Evidence chain (file:line)
    • Probe: SkiaWebChart/isSkiaWebSupported.ts — getContext('webgl2') at L21; its own header comment (L2-10) documents that it holds one context and returns true on ambiguous cases.
    • Shared web wrapper applies the probe once at mount: SkiaWebChart/index.tsx:63.
    • Both routes share the same dispatcher: SearchChartView → SearchBarChart/Line/Pie → @components/Charts → SkiaWebChart. Home mounts it at SpendOverTimeSectionContent.tsx:88; Search at components/Search/index.tsx:1015.
    • No chart-scoped ErrorBoundary anywhere in components/Charts/, components/Search/, or the SpendOverTimeSection tree. The only boundary is app-wide (App.tsx:131), and React boundaries can't catch async rAF/setTimeout throws anyway.
    • The throw string lives only in canvaskit-wasm (MakeWebGLCanvasSurface: if(!n||0>n) throw "failed to create webgl context: err "+n;); it does not fall back to MakeSWCanvasSurface when the context is 0.

    Alternative explanations considered: (a) A truly always-blocked GPU — already handled by the probe, so it wouldn't resurface. (b) getShaderPrecisionFormat returning null under memory pressure — that path returns false (empty state), so it's not the crashing path. The unguarded path is per-mount context-limit/allocation failure while the shared probe context stays valid, which fits the /search multi-chart aggravation and the "still 10 users/7d" tail.

    What changes do you think we should make in order to solve the problem?

    We can't force WebGL onto a machine that refuses it, so the goal is to stop the uncaught throw and degrade gracefully. In order of value:

    1. Cap concurrent live Skia canvases / dispose on unmount (addresses the /search regression directly). /search re-mounts charts across insight tabs; ensure a chart's WebGL context is released when it leaves view and avoid keeping multiple Skia canvases alive at once, so the per-page context cap isn't exhausted. This removes the most common trigger of the new crashes.
    2. Add a software-rendering fallback so CanvasKit stops throwing. A patch-package patch making the web renderer fall back to MakeSWCanvasSurface when GetWebGLContext returns 0 turns a fatal throw into a (slower) rendered chart. This is the only change that fully closes the async-throw gap, since neither try/catch nor an ErrorBoundary can catch it.
    3. As defense-in-depth, suppress this specific known-benign error at the Sentry beforeSend/global handler (match failed to create webgl context) so it stops counting as a crash while the chart degrades on its own. This is a noise fix, not a root-cause fix — do it alongside 1/2, not instead.

    Note the tension to respect: making the probe re-create a real per-mount context would catch more cases but reintroduces the context-churn false-negatives the current probe was written to avoid (isSkiaWebSupported.ts:8-10). Options 1+2 avoid that trap.

    What alternative solutions did you explore? (Optional)

    • Tightening the probe to create/destroy a context per mount — catches more, but resurfaces the mobile false-negative regression the current code deliberately guards against.
    • Suppressing the Sentry event only — hides the symptom but leaves a silently missing chart; only acceptable as defense-in-depth (option 3).

    Related issues


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/97104) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 27, 2026
  7. melvin-bot commented on Jul 27, 2026

    @melvin-bot

    Current assignee @truph01 is eligible for the External assigner, not assigning anyone new.

  8. melvin-bot commented on Jul 27, 2026

    @melvin-bot
  9. 19 remaining items

  10. melvin-bot commented on Aug 18, 2026

    @melvin-bot

    Current assignee @mallenexpensify is eligible for the Awaiting Payment assigner, not assigning anyone new.

  11. melvin-bot commented on Aug 18, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    Upwork Job

    • ROLE: @wildan-m paid $(AMOUNT) via Upwork (LINK)
    • Reviewer: @truph01 owed $250 via NewDot

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
  12. mallenexpensify commented on Aug 20, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @wildan-m paid $250 via Upwork
    Contributor+: @truph01 due $250 via NewDot

    @wildan-m can you please accept the job below? Please reply here and tag me once you have.
    If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal.
    https://www.upwork.com/jobs/~022081747685653182354

  13. wildan-m commented on Aug 22, 2026

    @wildan-m
    Contributor

    @mallenexpensify accepted, thanks

  14. mallenexpensify commented on Aug 24, 2026

    @mallenexpensify
    Contributor

    @wildan-m paid, summary updated above. Thx.

  15. garrettmknight commented on Sep 7, 2026

    @garrettmknight
    Contributor

    $250 approved for @truph01

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions