Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses an Android modal crash caused by invoking JNI-backed fragment comparisons (Fragment.Equals) after the underlying Java peer has been disposed, by adding guard checks and a safety-net exception handler in OnFragmentDestroyed.
Changes:
- Add
Handle != IntPtr.Zerochecks before comparingDialogFragmentinstances inOnFragmentDestroyed. - Catch
ObjectDisposedExceptionduring fragment comparison and pop the tracked fragment reference. - Add a patch entry to
CHANGELOG.mdfor version55.2.3.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/library/DIPS.Mobile.UI/API/Library/Android/FragmentLifeCycleCallback.cs |
Adds disposal guards/exception handling around fragment comparison to prevent JNI disposed-peer crashes when dismissing modals. |
CHANGELOG.md |
Adds a patch release entry documenting the Android modal crash fix. |
src/library/DIPS.Mobile.UI/API/Library/Android/FragmentLifeCycleCallback.cs
Outdated
Show resolved
Hide resolved
4 tasks
Contributor
Contributor
|
Alternatively, you can check |
eirinsvi
approved these changes
Mar 4, 2026
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.
Description of Change
Description of Change
Guard against disposed Java peer objects in
FragmentLifeCycleCallback.OnFragmentDestroyedon Android to prevent a crash when comparing dialog fragments.Problem
On Android, a crash occurs with
Cannot access disposed object with JniIdentityHashCode=...when a modal is dismissed. TheOnFragmentDestroyedcallback retrieves aDialogFragmentfrom aWeakReferencestack and callsFragment.Equals()— a JNI-bridged method. By the time this callback fires, the underlying Java peer can already be disposed while the managed .NET wrapper is still alive, causingAssertSelfto throw.Solution
Handle != IntPtr.Zeroon both fragment references before calling.Equals(), sinceHandlebecomes zero when the Java peer is disposedObjectDisposedExceptionas a safety net for any remaining race window, popping the stack since the fragment is destroyed regardlessPlatform Differences