Repository navigation
Description
Description
An empty CollectionView can queue work in ItemsViewHandler.UpdateEmptyViewSize
and then disconnect before that work executes. The queued callback accesses the
handler's typed PlatformView getter, which throws after disconnection, causing a
fatal exception on Android's main thread.
The attached standalone solution defines its pages and empty CollectionView in
XAML. A button explicitly forces the measure/disconnect ordering in one UI-thread
turn. It reproduces the framework callback exception without custom handlers,
reflection, fabricated exceptions, networking, or application-specific code.
The original report occurred during ordinary app navigation. This sample isolates
the callback lifetime problem; it does not claim that explicit disconnection in a
button handler was the original trigger.
Steps to Reproduce
These steps are based on using the sample repository provided
- Open PlatformViewCollection.sln and run the Android project with MAUI 10.0.90.
The same failure was also reproduced with 10.0.101. - Wait for the main page to render.
- Tap Run crash probe once.
- Observe the fatal main-thread exception in UpdateEmptyViewSize's callback.
As a control, relaunch and tap Run connected control. The empty view renders
and the app remains running. Both buttons perform the same attachment and
measurement; only the crash probe removes and disconnects the handler.
Before measuring, the sample checks that the RecyclerView is attached, its adapter
is EmptyViewAdapter, and its empty-view holder has not yet been created. The
critical sequence is:
handler.GetDesiredSize(317, 241);
ListHost.Content = null;
handler.DisconnectHandler();
There is no await between these operations. If the native preconditions are not
met, the screen reports that and does not attempt the sequence.
Expected behavior
An asynchronous layout callback should safely return if its owning handler has
disconnected, rather than accessing a getter that throws after teardown.
Actual behavior
The sample logs successful preconditions and a null platform view after handler
disconnection, followed by the framework exception:
Probe 1: attached=true, EmptyViewAdapter=true, holder=false, disconnect=True.
Handler disconnected; PlatformView is null: True. Returning to Android's UI loop.
FATAL EXCEPTION: main
Process: com.example.platformviewcollection
android.runtime.JavaProxyThrowable: [System.InvalidOperationException]: PlatformView cannot be null here
at Microsoft.Maui.Handlers.ViewHandler`2.get_PlatformView()
at Microsoft.Maui.Controls.Handlers.Items.ItemsViewHandler`1
.<>c__DisplayClass17_0.<UpdateEmptyViewSize>b__0()
at Java.Lang.Thread+RunnableImplementor.Run
This excerpt is shortened for readability. Full captured stacks are in
docs/evidence, including a fresh-launch reproduction and a 10.0.101 comparison.
Link to public reproduction project repository
https://github.com/SotoOnGit/PlatformViewCollection
Version with bug
10.0.90
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
No response
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 8 and up
Did you find any workaround?
A potential soultion would be not using CollectionView.EmptyView property for the meanwhile and encapsulating both collection view and its empty view in a grid parent with visibility toggles.
Relevant log output
Extract from sample repo docs/evidence
--------- beginning of main
09-14 00:17:34.220 3774 3774 I PlatformViewCollection: Probe 2: attached=true, EmptyViewAdapter=true, holder=false, disconnect=True.
09-14 00:17:34.519 3774 3774 I PlatformViewCollection: Handler disconnected; PlatformView is null: True. Returning to Android's UI loop.
--------- beginning of crash
09-14 00:17:34.776 3774 3774 E AndroidRuntime: FATAL EXCEPTION: main
09-14 00:17:34.776 3774 3774 E AndroidRuntime: Process: com.example.platformviewcollection, PID: 3774
09-14 00:17:34.776 3774 3774 E AndroidRuntime: android.runtime.JavaProxyThrowable: [System.InvalidOperationException]: PlatformView cannot be null here
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=10.0.0.0, Culture=neutral, PublicKeyToken=null],[AndroidX.RecyclerView.Widget.RecyclerView, Xamarin.AndroidX.RecyclerView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_PlatformView + 0x14(Unknown Source)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at Microsoft.Maui.Controls.Handlers.Items.ItemsViewHandler`1+<>c__DisplayClass17_0[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=10.0.0.0, Culture=neutral, PublicKeyToken=null]].<UpdateEmptyViewSize>b__0 + 0x0(Unknown Source)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at Java.Lang.Thread+RunnableImplementor.Run + 0x8(Unknown Source)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at Java.Lang.IRunnableInvoker.n_Run + 0xe(Unknown Source)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at mono.java.lang.RunnableImplementor.n_run(Native Method)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:995)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:103)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:248)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at android.os.Looper.loop(Looper.java:338)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:9067)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
09-14 00:17:34.776 3774 3774 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932)
Activity
LogishaSelvarajSF4525 commentedon Sep 15, 2026
This issue has been validated in Visual Studio Code 1.137.0 with .NET MAUI versions 10.0.0, 10.0.90 and 10.0.101. It can be reproduced on Android 8(API 26) platform. Here I attached the output video & image reference:
Issue reproduced:
Screen.Recording.2026-09-15.at.1.50.17.PM.mov
[Android] Prevent CollectionView EmptyView crash after handler discon…
[Android] Prevent CollectionView EmptyView crash after handler discon…
[Android] Prevent CollectionView EmptyView crash after handler discon…
[Android] Prevent CollectionView EmptyView crash after handler discon…
[Android] Prevent CollectionView EmptyView crash after handler discon…
[Android] Prevent CollectionView EmptyView crash after handler discon…
[Android] Prevent CollectionView EmptyView crash after handler discon…
[Android] Prevent CollectionView EmptyView crash after handler discon…
kubaflo commentedon Oct 10, 2026
Thank you for the report and the investigation details. We are closing this as completed: the Android CollectionView EmptyView callback captures the native RecyclerView and checks handler identity before access, avoiding the typed PlatformView getter after disconnect.
Supporting evidence: #38653 (merged into
inflight/current).This records the merged source change; it does not imply that the fix is present in every released .NET MAUI package.
If you can still reproduce the reported behavior in a build that includes the linked change, please comment here with the exact version and reproduction details so we can reopen and investigate. The existing reproduction and discussion remain available; a new issue is not required.
[Android] Prevent CollectionView EmptyView crash after handler discon…
[Android] Prevent CollectionView EmptyView crash after handler discon…
[Android] Prevent CollectionView EmptyView crash after handler discon…
[Android] Prevent CollectionView EmptyView crash after handler discon…
[Android] Prevent CollectionView EmptyView crash after handler discon…
[Android] Prevent CollectionView EmptyView crash after handler discon…