Skip to content

[Android 16][Fabric] Crash: java.lang.IllegalStateException: addViewAt: failed to insert view during GistModalActivity transition #590

@ankitminhas-aspire

Description

@ankitminhas-aspire

SDK version: 4.2.5

Environment: Production

Are logs available?
Yes. Detailed Datadog stack trace and lifecycle breadcrumbs are included below.

Describe the bug
A fatal java.lang.IllegalStateException occurs on Android 16 when using the New Architecture (Fabric). The crash happens specifically during the transition when an In-App message (Gist) is being mounted over a React Native surface.

The error addViewAt: failed to insert view [48] into parent [50] indicates that the Fabric renderer is attempting to attach a view that is already attached to another parent. This is a synchronization conflict between the Gist engine and the Fabric Mounting Manager.

To Reproduce

Enable New Architecture (Fabric) in a React Native app.

Target Android 16.

Use version 4.2.5 of the SDK.

triggers an In-App Message before opening the app.

As the app navigates or mounts a view (e.g., "Dashboard"), the GistModalActivity launches to show the message.

The app crashes with java.lang.IllegalStateException. This is from sentry logs we are not able to reproduce at our end but many sentry logs

Exception - This event
error
RuntimeException: Exception thrown when executing UIFrameGuarded

Device Orientation
info
{
  position: portrait
}

Ui Lifecycle
info
{
  screen: MainActivity,
  state: resumed
}

Ui Lifecycle
info
{
  screen: GistModalActivity,
  state: paused
}

Expected behavior
The In-App Message modal should mount and display without conflicting with the React Native Fabric view hierarchy.

Screenshots
NA

Additional context
The crash occurs immediately after the GistModalActivity reaches the resumed state. According to our Datadog breadcrumbs, the timeline is:

MainActivity pauses.

GistModalActivity is created/started/resumed.

Assets (tasks.svg, search.svg) are fetched for the modal.

The UI thread crashes while executing FabricUIManager.scheduleMountItem.

Stack Trace

java.lang.IllegalStateException: addViewAt: failed to insert view [48] into parent [50] at index 0

at com.facebook.react.fabric.mounting.SurfaceMountingManager.addViewAt(Unknown Source:249)
at com.facebook.react.fabric.mounting.mountitems.IntBufferBatchMountItem.execute(Unknown Source:255)
at com.facebook.react.fabric.mounting.MountItemDispatcher.executeOrEnqueue(Unknown Source:53)
...

Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

at android.view.ViewGroup.addViewInner(ViewGroup.java:5539)
at com.facebook.react.views.view.ReactClippingViewManager.addView(SourceFile:6)
at com.facebook.react.fabric.mounting.SurfaceMountingManager.addViewAt(Unknown Source:196)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions