[Android][Fabric] "Unable to remove a view from a view that is not a ViewGroup" still crashes with fixDifferentiatorParentTagForUnflattenCase enabled (0.86.2)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
研究方向
先閱讀 SurfaceMountingManager.kt 中的 removeViewAt,並透過 IntBufferBatchMountItem.kt 和 MountItemDispatcher.kt 追蹤 Remove batch。將行為與 #56542 中的 fix 進行比較,並調查所描述的 orientation 與 conditional re-render 順序;完成的標準是找出並涵蓋仍會發出無效 parent tag 的路徑,而不依賴僅在 production 中發生的 crash。
由索引模型根據 Issue 內容生成。
描述
Description
We are still seeing the fatal Android Fabric crash
java.lang.IllegalStateException: Unable to remove a view from a view that is not a ViewGroup. ParentTag: 1902 - Tag: 1900 - Index: 0
in production with fixDifferentiatorParentTagForUnflattenCase enabled, on stock React Native 0.86.2 (new architecture, bridgeless, Hermes).
After #56542 ("Fix parentTagForUpdate in unflatten-unflatten branch") we backported the fix by force-enabling the flag at startup:
// Application.onCreate, after loadReactNative(this)
ReactNativeFeatureFlags.dangerouslyForceOverride(
object : ReactNativeNewArchitectureFeatureFlagsDefaults() {
override fun fixDifferentiatorParentTagForUnflattenCase(): Boolean = true
}
)
We verified the override is effective (the dangerouslyForceOverride return value confirms the flag had not been read before the override, and the override happens in Application.onCreate before any surface is mounted). The crash volume dropped after enabling the flag, but the crash recurred in a build that provably contains it — so at least one more differ reparenting path can still emit a Remove mutation against a wrong parent tag (a tag whose ViewState holds a null or non-ViewGroup view, i.e. a non-container or a never-materialized/non-layoutable node).
Occurrence details from the crash session (Crashlytics):
- Device: Samsung SM-S938W (Galaxy S25 Ultra), Android 16
- The crashing tags (1900/1902) are mid-session views, not first-render views
- Timeline: the session had two device orientation changes (portrait → landscape → portrait), then a large state-driven re-render (a BLE device connected and the dashboard swapped several conditional subtrees), and the crash fired ~7 s after that re-render began
- The same differ family also produces the sibling hard throw
"Cannot remove child at index X from parent ViewGroup"reported elsewhere (e.g. software-mansion/react-native-screens#2491)
Stack (top frames):
Fatal Exception: java.lang.IllegalStateException: Unable to remove a view from a view that is not a ViewGroup. ParentTag: 1902 - Tag: 1900 - Index: 0
at com.facebook.react.fabric.mounting.SurfaceMountingManager.removeViewAt(SurfaceMountingManager.kt:444)
at com.facebook.react.fabric.mounting.mountitems.IntBufferBatchMountItem.execute(IntBufferBatchMountItem.kt:125)
at com.facebook.react.fabric.mounting.MountItemDispatcher.executeOrEnqueue(MountItemDispatcher.kt:379)
at com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchMountItems$lambda$7$lambda$6(MountItemDispatcher.kt:269)
at com.facebook.react.internal.tracing.PerformanceTracer.trace(PerformanceTracer.kt:46)
at com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchMountItems(MountItemDispatcher.kt:250)
at com.facebook.react.fabric.mounting.MountItemDispatcher.tryDispatchMountItems(MountItemDispatcher.kt:94)
at com.facebook.react.fabric.FabricUIManager$DispatchUIFrameCallback.doFrameGuarded(FabricUIManager.java:1624)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.kt:42)
at com.facebook.react.modules.core.ReactChoreographer.frameCallback$lambda$1(ReactChoreographer.java:58)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1899)
...
We could not reproduce locally (hundreds of scripted navigations/re-renders on the same screens stay clean); the reparenting race appears to need production timing. We're reporting because the flag from #56542 finished rollout and is default-true on main, so this evidences that the unflatten wrong-parent-tag family is not fully closed.
Workaround we ship meanwhile (in case it helps other affected apps): a build-time ASM transform that wraps SurfaceMountingManager.removeViewAt in try/catch (IllegalStateException) → log non-fatal → skip the remove. This matches the method's existing soft-fail handling of its other inconsistency cases, and addViewAt already self-heals a child that is still attached elsewhere. Not proposing that upstream — the differ emitting the wrong parent tag is the actual bug.
Happy to provide more Crashlytics context (thread dumps, breadcrumb timeline) on request.
Steps to reproduce
No deterministic repro. Observed pattern: device rotation (two orientation changes) followed by a large conditional re-render that flattens/unflattens nested views; crash fires during a subsequent mount batch.
React Native Version
0.86.2
Affected Platforms
Runtime - Android
Areas
Fabric - The New Renderer
Output of npx @react-native-community/cli info
React Native: 0.86.2 (new architecture, bridgeless)
React: 19.2.8
Expo: 57.0.4
Hermes: bundled
OS observed crashing: Android 16 (Samsung SM-S938W)
compileSdk/targetSdk: 36, minSdk: 24
AGP: 8.12.0, Gradle: 9.3.1
- 主要語言
- C++
- 星號
- 127k
- 分支
- 25.3k
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
react/react-native 的其他 Issue
-
Needs: Author Feedback Needs: Repro
難度 2/5 1-3 小時 新手友好度 76/100
react/react-native#58952 · 1 則留言 ·
維護者通常 1 天內回覆
-
Needs: Attention Needs: Repro
難度 2/5 1-3 小時 新手友好度 78/100
react/react-native#58904 · 2 則留言 ·
維護者通常 1 天內回覆
-
Needs: Author Feedback Needs: Repro
難度 2/5 1-3 小時 新手友好度 75/100
react/react-native#58659 · 2 則留言 ·
維護者通常 1 天內回覆
-
Needs: Author Feedback Needs: Repro
難度 1/5 1 小時以內 新手友好度 92/100
react/react-native#58621 · 1 則留言 ·
維護者通常 1 天內回覆
-
Add TypeScript declaration for the performance global可能已有人在做 @Cedric921 於 7 天前認領。 未關閉Needs: Attention Needs: Repro
難度 2/5 1-3 小時 新手友好度 85/100
react/react-native#58610 · 4 則留言 ·
維護者通常 1 天內回覆
查看 react/react-native 的全部 Issue
相似的 Issue
-
c++ good first issue M2: audio plumbing no hardware needed tests
難度 2/5 1-3 小時 新手友好度 85/100
GageLawton/noise-cancellation#23 ·
維護者通常 1 天內回覆
-
Bug
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
nullmoth/nvidia-macos-driver#126 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
objectionary/eo-graphs#85 ·
-
bug derived types format I/O medium priority semantics
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆