Skip to content

fix(android): exclude ad views from instance state saving - #874

Merged
mikehardy merged 1 commit into
invertase:mainfrom
philipheinser:fix/android-exclude-ad-views-from-instance-state
Aug 17, 2026
Merged

fix(android): exclude ad views from instance state saving#874
mikehardy merged 1 commit into
invertase:mainfrom
philipheinser:fix/android-exclude-ad-views-from-instance-state

Conversation

@philipheinser

Copy link
Copy Markdown
Contributor

Description

Banner and native ad views can crash on Android when a fragment (for example react-native-screens) restores view hierarchy state.

Mediation adapters such as Facebook Audience Network persist view state under small view ids. Those ids collide with React Native view tags, which produces:

Wrong state class, expecting View State but received
com.facebook.ads.internal.util.parcelable.WrappedParcelable

This disables instance-state save/restore on the ad view wrappers so parent fragments no longer restore adapter-owned state.

Related issues

None.

Release Summary

fix(android): exclude ad views from instance state saving to prevent mediation adapter crashes

Checklist

  • I read the Contributor Guide
    and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
  • My change includes tests;
    • e2e tests added or updated in __tests__e2e__
    • jest tests added or updated in __tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

Reproduced by navigating away from a screen that shows a GAM banner or native ad mediated by Facebook Audience Network, then returning so react-native-screens restores the fragment view state. Without this change the activity crashes; with setSaveFromParentEnabled(false) / isSaveFromParentEnabled = false the restore succeeds.

🔥

Mediation adapters such as Facebook Audience Network persist view state
under small view ids that collide with React Native view tags, crashing
when react-native-screens restores fragment state.
@dylancom
dylancom requested a review from mikehardy August 15, 2026 20:23

@mikehardy mikehardy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice - thanks for this fix @philipheinser - it looks spot on

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.35%. Comparing base (a34c7ba) to head (6649ce6).
⚠️ Report is 246 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #874      +/-   ##
==========================================
- Coverage   43.72%   39.35%   -4.37%     
==========================================
  Files          30       36       +6     
  Lines         549      671     +122     
  Branches      151      169      +18     
==========================================
+ Hits          240      264      +24     
- Misses        309      407      +98     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mikehardy

Copy link
Copy Markdown
Collaborator

ios failure is an unrelated e2e flake, I'll shore that up in an e2e pass shortly. this is good to go

@mikehardy
mikehardy merged commit 2d130c4 into invertase:main Aug 17, 2026
8 of 10 checks passed
@mikehardy

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 16.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants