Skip to content

(fix): fix method to deallocate reactNativeFactory instance for expo#347

Merged
artus9033 merged 1 commit into
callstack:mainfrom
marcinszalski-callstack:feature/134_fix_method_to_deallocate_reactnativefactory_instance
May 25, 2026
Merged

(fix): fix method to deallocate reactNativeFactory instance for expo#347
artus9033 merged 1 commit into
callstack:mainfrom
marcinszalski-callstack:feature/134_fix_method_to_deallocate_reactnativefactory_instance

Conversation

@marcinszalski-callstack
Copy link
Copy Markdown
Contributor

Summary

This PR breaks the strong reference-cycle by niling the reactHost instance from the view factory.

The location of the Stop React Native has been changed, now it's in the top card. It changed its name too - to Stop RN.

Simulator Screenshot - iPhone 16e - 2026-05-22 at 11 05 08

Test plan

  1. Run Expo54/Expo55 app on iOS
  2. Push the Stop RN button

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to ensure the Expo runtime can be fully deallocated by breaking a strong reference cycle (by clearing reactHost from the root view factory) and updates the AppleApp sample UI to move/rename the stop control.

Changes:

  • In Expo iOS runtime shutdown, attempts to nil out the root view factory’s reactHost before releasing the factory.
  • Moves the “Stop React Native” control from ContentView into the GreetingCard and renames it to “Stop RN”.
  • Adds a patch changeset for @callstack/react-native-brownfield.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/react-native-brownfield/ios/Expo/ExpoHostRuntime.swift Adds a shutdown step to clear reactHost on the root view factory before releasing the Expo RN factory.
apps/AppleApp/Brownfield Apple App/components/GreetingCard.swift Adds “Stop RN” button to the top card and imports ReactBrownfield to call stop.
apps/AppleApp/Brownfield Apple App/components/ContentView.swift Removes the previous “Stop React Native” button from below the RN card.
.changeset/silly-wolves-thank.md Declares a patch release for the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +68 to +69
if let rootViewFactory = reactNativeFactory?.rootViewFactory {
(rootViewFactory as AnyObject).setValue(nil, forKey: "reactHost")
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.

I don't think that would happen. CC @hurali97

Copy link
Copy Markdown
Collaborator

@artus9033 artus9033 left a comment

Choose a reason for hiding this comment

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

LGTM!

@artus9033 artus9033 merged commit c19a81b into callstack:main May 25, 2026
11 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.

4 participants