Say which views the sheet moved, so a mounting crash can be attributed - #5
Open
sergeymild wants to merge 1 commit into
Open
sergeymild wants to merge 1 commit into
sergeymild wants to merge 1 commit into
Conversation
…ributed
The crashes worth chasing name nothing of ours on Android: "addViewAt: failed to
insert view [child] into parent [parent] at index N", caused by
"IndexOutOfBoundsException: index=N count=0", with a stack made only of React
Native and framework frames. On iOS the symbols are ours
(HostFittedSheet.setFittedSheetParams, dismissSheet inside
RCTMountingManager.performTransaction) but the state that led there is not.
So the library says it itself. SheetTreeLog records every place where a view
React Native believes it owns is moved by us, naming views the way the crash
report names them - by the React tag on Android, by tag and address on iOS:
host.addView the previous child is dropped without React Native hearing
host.removeView / host.removeViewAt
sheet.addView an overlay child never reaches mHostView, yet
getChildCount goes on counting it
sheet.removeView / sheet.removeViewAt
sheet.detachHost the host leaves the dialog container on dismiss
inline.attachOverlay / dialog.attachOverlay
the overlay is re-parented out of whatever parent React
Native gave it
sheet.insertReactSubview / sheet.removeReactSubview / sheet.attachOverlay /
sheet.destroy the same on iOS
host.mountChild / host.unmountChild / host.prepareForRecycle
what the mounting layer asked for, and where the
HostFittedSheet is thrown away and rebuilt
Entries go to logcat under Sheet2Tree and to the unified log under com.sheet2,
to a 32-entry ring, and on Android to JS as a "sheet2:tree" event.
addSheetTreeListener turns them into app breadcrumbs - which is what survives
into a native crash report - and getSheetTreeLog() reads the ring, the only
channel iOS has for now.
Nothing changes in behaviour: the same views are moved the same way. The two
leftover println("😀 ...") debug lines go with it.
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.
Why
Two crash families in the MuseScore app land in the mounting layer around a sheet, and neither can be attributed to this library from the report alone:
IllegalStateException: addViewAt: failed to insert view [child] into parent [parent] at index N, caused byIndexOutOfBoundsException: index=N count=0. The stack betweenViewGroupManager.addViewandViewGroup.addInArrayis React Native and framework frames only, so nothing says a sheet was involved. 29 users / 56 events a fortnight (ANDROID-1BXY, plusANDROID-1D04arriving through worklets). All six events inspected happen right after returning from Google'sSignInHubActivity— a sign-in that starts from a sheet.EXC_BAD_ACCESSinsideRCTMountingManager.performTransaction, atHostFittedSheet.setFittedSheetParamsand arounddismissSheet(IOS-5AA0,IOS-50QZ, ~490 users). Here the symbols are ours, but the state that led there is not recorded anywhere.This library legitimately moves views React Native believes it owns, and there are several such places. Which of them (if any) is behind those crashes cannot be answered without saying, at the time it happens, which views were moved.
What this adds
SheetTreeLogon both platforms, recording every one of those moves and naming views the way a crash report names them — the React tag on Android, tag and address on iOS:host.addViewhost.removeView,host.removeViewAtsheet.addViewmHostView, yetgetChildCount()goes on counting itsheet.removeView,sheet.removeViewAtsheet.detachHostinline.attachOverlay,dialog.attachOverlaysheet.insertReactSubview,sheet.removeReactSubview,sheet.attachOverlay,sheet.destroyhost.mountChild,host.unmountChild,host.prepareForRecycleHostFittedSheetis thrown away and rebuiltWhere the entries go:
Sheet2Tree, and the unified log under thecom.sheet2subsystem;sheet2:treeevent —addSheetTreeListener()is meant to be wired to breadcrumbs, which is what survives into a native crash report;getSheetTreeLog()reads the ring, the only channel iOS has for now.Behaviour is unchanged: the same views are moved the same way. The two leftover
println("😀 ...")debug lines go with it.Verified
:react-native-sheet2:compileDebugKotlinin the consuming app, including the codegen for the newgetTreeLog()on the module spec.— so the native → JS chain works end to end.
swiftc -parseon the new Swift file. The iOS app build is not part of this checkout; the consuming app builds it next.🤖 Generated with Claude Code