Skip to content

fix: Handle exceptions from child views during drawing operations#3593

Open
erhard-pspdfkit wants to merge 1 commit intosoftware-mansion:mainfrom
erhard-pspdfkit:handle-child-view-drawing
Open

fix: Handle exceptions from child views during drawing operations#3593
erhard-pspdfkit wants to merge 1 commit intosoftware-mansion:mainfrom
erhard-pspdfkit:handle-child-view-drawing

Conversation

@erhard-pspdfkit
Copy link

@erhard-pspdfkit erhard-pspdfkit commented Jan 30, 2026

Description

During navigation transitions, ScreenStack.performDraw() can attempt to draw child views that are being recycled or destroyed. If an IllegalStateException or RuntimeException is thrown by a UI library when their views are drawn while in an invalid state, the app crashes.

The Android drawing system queues drawing operations during navigation transitions. When views are recycled before these operations execute, child views may throw exceptions that propagate up to react-native-screens's ScreenStack.performDraw(), crashing the app.

Add exception handling in performDraw() to gracefully handle exceptions from child views during drawing operations. This is a defensive practice that improves robustness without affecting normal operation.

Changes

  • Wrap super.drawChild() in try-catch to handle IllegalStateException and RuntimeException
  • Silently ignore exceptions from child views during drawing (view is already being recycled)
  • Maintain existing behavior for normal drawing operations

Checklist

  • Included code example that can be used to test this change.
  • Updated / created local changelog entries in relevant test files.
  • For visual changes, included screenshots / GIFs / recordings documenting the change.
  • For API changes, updated relevant public types.
  • Ensured that CI passes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant