Repository navigation
[Android] NullPointerException in Paint.set (mNativePaint null) during StaticTextLayout draw after page SizeChanged #39317
Description
Description
Description
Intermittent fatal crash on Android during the draw pass of a page that was just navigated to. The NullPointerException is thrown inside the Android framework (Paint.set → MeasuredParagraph.applyMetricsAffectingSpan) while MAUI's StaticTextLayout constructs a StaticLayout from LayoutViewGroupExt.dispatchDraw. The native Paint backing the layout appears to be null/recycled while the draw is in flight. No app code is in the stack.
Stack trace (main thread, unhandled)
java.lang.NullPointerException: Attempt to read from field 'long android.graphics.Paint.mNativePaint' on a null object reference in method 'void android.graphics.Paint.set(android.graphics.Paint)'
android.graphics.Paint.set (Paint.java:771)
android.text.TextPaint.set (TextPaint.java:67)
android.text.MeasuredParagraph.applyMetricsAffectingSpan (MeasuredParagraph.java:822)
android.text.MeasuredParagraph.buildForStaticLayoutInternal (MeasuredParagraph.java:603)
android.text.MeasuredParagraph.buildForStaticLayout (MeasuredParagraph.java:532)
android.text.PrecomputedText.createMeasuredParagraphs (PrecomputedText.java:527)
android.text.StaticLayout.generate (StaticLayout.java:869)
android.text.StaticLayout.<init> (StaticLayout.java:736)
crc640360c8a960a6805b.StaticTextLayout.<init>
crc6486af4e8104107bae.LayoutViewGroupExt.dispatchDraw
android.view.ViewGroup.drawChild / dispatchDraw / View.updateDisplayListIfDirty / View.draw (repeated)
Occurrences
4 events so far, always right after Page.SizeChanged on first layout of a freshly navigated page (NavigationPage push, 2 different pages with plain Label/text content):
| Date | App build | Device | OS |
|---|---|---|---|
| 2026-09-15 | 4.0.2.0 | Ulefone Armor Pad (3.7 GB RAM) | Android 12 |
| 2026-09-23 | 4.0.3.0 | Lenovo TB336ZU (8 GB) | Android 16 |
| 2026-10-05 | 4.0.4.0 | Lenovo TB336ZU | Android 16 |
| 2026-10-12 | 4.0.4.1 | Lenovo TB336ZU (landscape) | Android 16 |
Not low-memory at crash time (low_memory: false). Release build, Play Store install.
Steps to reproduce
Not deterministic. Occurs when navigating (push) to a page with many Labels/custom layouts, shortly after the previous page was popped or navigated away from; the crash arrives right after the new page's SizeChanged.
Expected behavior
No crash during draw.
Environment
- .NET MAUI:
- Target: net10.0-android
- Devices/OS: see table above
- Third-party UI: Syncfusion MAUI controls are used elsewhere in the app, though no Syncfusion frames appear in this trace.
Notes
The stack is entirely framework + MAUI-generated bindings. Possibly related to other "PlatformView is null / handler disconnected while views are still drawn" reports during page transitions. Happy to provide the Sentry event or a minimal repro if guidance is given on what to look for.
Steps to Reproduce
Not deterministic. Navigate (push) to a page with many Labels/custom layouts shortly after leaving the previous page; crash occurs right after the new page’s SizeChanged. Expected: no crash. Actual: fatal NullPointerException.
Link to public reproduction project repository
No response
Version with bug
10.0.110
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
No response
Activity
LogishaSelvarajSF4525 commentedon Oct 12, 2026
This issue has been validated in Visual Studio Code 1.141.0 with .NET MAUI versions 10.0.0, 10.0.100 and 10.0.110. It cannot be reproducible on the Android(API 30 & API 36) platform. Here I attached the sample & video for reference: TriageApp 1.zip
Issue not reproduced:
Screen.Recording.2026-10-12.at.4.40.02.PM.mov
Ahamed-Ali commentedon Oct 12, 2026
#39317 (comment) Based on the information provided, we have created a sample to reproduce the issue, but we have been unable to reproduce the reported behavior.
Could you please share a sample project that reliably reproduces the issue? This would help us reproduce the behavior and investigate the root cause further. @lauraruggerilinea
dotnet-policy-service commentedon Oct 12, 2026
Hi @@lauraruggerilinea. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
dotnet-policy-service commentedon Oct 12, 2026
Hi @@lauraruggerilinea. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
dotnet-policy-service commentedon Oct 12, 2026
Hi @lauraruggerilinea. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
dotnet-policy-service commentedon Oct 12, 2026
Hi @lauraruggerilinea. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
lauraruggerilinea commentedon Oct 13, 2026
Thanks for looking into this. I pulled the full data for all 5 Sentry events (correction to the original report: 5 events, not 4).
Why a minimal repro is hard to provide
I don't think I can offer a reliable repro project. The crash happened 5 times in about a month, on real tablets, in a production app with a lot of data. It is a timing race, so a trivial sample that navigates between two pages won't hit it. That also matches what the contributors saw (no repro on 10.0.0, 10.0.100 and 10.0.110, API 30 and 36). I'd rather say that than leave the issue waiting on something I can't deliver.
What I can offer instead: the pattern in the telemetry
low_memoryis false in every event, with about 3.3–3.8 GB free on the 8 GB Lenovo.BorderorVerticalStackLayout.A.DisappearingandB.Appearingfire in the same millisecond. B is a new page (in 4 events a payment page, in 1 a lines page).B.SizeChangedfires.LayoutViewGroupExt.dispatchDraw→StaticTextLayout→Paint.set(Paint)→ NPE onmNativePaint.Hypothesis
This looks like a race between teardown of the previous page and the first draw pass of the new one. A
Paintused byStaticTextLayout(or its cache) seems to be released or recycled by the timedispatchDrawruns. Could someone familiar withStaticTextLayoutcheck whether aPaintcan be used after the view is detached or recycled? That would be more useful than a sample app.If the team wants specific data (more events, a native tombstone, custom logging in a build), I'm happy to collect it from the production devices.