Skip to content

fix(iOS, Tabs): weak-capture tab bar item and screen view in async image callbacks#4111

Merged
kkafar merged 2 commits into
software-mansion:mainfrom
cortinico:nc/ios-26-patch
Jun 3, 2026
Merged

fix(iOS, Tabs): weak-capture tab bar item and screen view in async image callbacks#4111
kkafar merged 2 commits into
software-mansion:mainfrom
cortinico:nc/ios-26-patch

Conversation

@cortinico

Copy link
Copy Markdown
Contributor

Description

Avoid updating a tab bar item whose internal view hierarchy has been
torn down. This works around an iOS 26 UIKit regression where unowned
refs inside UITabBarItem._updateViewAndPositionItems: cause crashes.

Both the normal icon and selected icon completion blocks now:

  1. Weak-capture tabBarItem and screenView before the block
  2. Promote to strong refs inside the block and bail if either is nil
  3. Guard that the screen's controller is still parented by a UITabBarController

Before & after - visual documentation

TBA

Test plan

Discussed offline

Checklist

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

…llbacks

Avoid updating a tab bar item whose internal view hierarchy has been
torn down. This works around an iOS 26 UIKit regression where unowned
refs inside UITabBarItem._updateViewAndPositionItems: cause crashes.

Both the normal icon and selected icon completion blocks now:
1. Weak-capture tabBarItem and screenView before the block
2. Promote to strong refs inside the block and bail if either is nil
3. Guard that the screen's controller is still parented by a UITabBarController
@kkafar kkafar force-pushed the nc/ios-26-patch branch from f0cec5c to 356b62f Compare June 3, 2026 09:02
The semantics look okayish. It won't hurt to add guard checks for
whether the `tabBarItem` / `screenView` has not been dealocated in the
meantime or it has been detached from the tab bar.

One thing though is that when reattaching to window -> it is likely that
we need to trigger appearance update.

@kkafar kkafar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hello!

I can not really reproduce the issue, but it won't hurt to add a null-guard & verify whether we have been not detached from the parent controller since block-schedule-time.

One thing though -> this slightly changes semantics. Earlier, even if we were detached from the parent controller, the update would go through, effectively setting tabBarItem.image / tabBarItem.selectedImage. Now it won't. This implies that we might need to take care of reapplying the appearance at the moment we receive didMoveToParentViewController on RNSTabsScreenViewController.

I'll look into it.

@kkafar kkafar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay, we already request appearance update on didMoveToParentViewController.

Seems fine then.

@kkafar kkafar changed the title fix(ios): weak-capture tab bar item and screen view in async image callbacks fix(iOS, Tabs): weak-capture tab bar item and screen view in async image callbacks Jun 3, 2026
@kkafar kkafar marked this pull request as ready for review June 3, 2026 09:59
@kkafar kkafar merged commit a6bfad8 into software-mansion:main Jun 3, 2026
6 checks passed
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.

2 participants