Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Fix Updates.reloadAsync crash issue #19538

Merged
merged 1 commit into from Oct 13, 2022
Merged

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Oct 13, 2022

Why

fix Updates.reloadAsync crashes on current sdk-46.
close ENG-6714

How

following up with #19176, the NativeModulesProxy doesn't be recreated for other cases. the Updates.reloadAsync uses ReactInstanceManager.recreateReactContextInBackground in release build mode and more chance to come across the race condition issue. the ReactApplicationContext in NativeModulesProxy is old and destroyed, the CatalystInstanceImpl.getJSCallInvokerHolder will throw NPE and cause the crash.

basically, the issue should be resolved on main branch because the KotlinInteropModuleRegistry.shouldBeRecreated also checks the liveness of the underlying ReactApplicationContext. i think to check the context from NativeModulesProxy would be more straightforward.

i will create another pr for sdk-46 fix.

Test Plan

based on https://github.com/keith-kurak/updates-reload-issue + patch-package

Checklist

@linear
Copy link

linear bot commented Oct 13, 2022

ENG-6714 Crash on Updates.reloadAsync() (reported by RBI)

Original issue report: https://exponent-internal.slack.com/archives/C02VC9BLMQW/p1665498344977319

Here's a reproduction repo: https://github.com/keith-kurak/updates-reload-issue/tree/main

And a build that demonstrates the issue (confirmed on Android 12 emulator): https://expo.dev/accounts/keith-kurak/projects/updates-reload-issue/builds/05525183-a505-48b4-86fc-c361f17a46dc

How to reproduce:

  • Install the build
  • Press the "Just Reload" button repeatedly.

The app should crash with the Cannot install JSI interop error intermittently. It seems to increase as more affected packages are added, happening 10% of the time with just expo-linear-gradient and 20% with both expo-linear-gradient and expo-localization added. If neither of those packages are installed, the error/ crash does not occur.

@expo-bot
Copy link
Collaborator

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) 👇

⚠️ Suggestion: Missing changelog entries


Your changes should be noted in the changelog. Read Updating Changelogs guide and consider adding an appropriate entry to the following changelogs:


Generated by ExpoBot 🤖 against 5fe6117

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Oct 13, 2022
@Kudo Kudo marked this pull request as ready for review October 13, 2022 17:32
@Kudo Kudo requested a review from tsapeta as a code owner October 13, 2022 17:32
@Kudo Kudo merged commit 96c7bed into main Oct 13, 2022
@Kudo Kudo deleted the @kudo/fix-emc-reload-issue branch October 13, 2022 17:32
Kudo added a commit that referenced this pull request Oct 13, 2022
# Why

same as #19538 but for sdk-46

# How

apply the same patch as #19538 and resolve conflict

# Test Plan

based on https://github.com/keith-kurak/updates-reload-issue + patch-package
lukmccall added a commit that referenced this pull request Nov 16, 2022
…loading on Android (#20063)

# Why

Closes #20033.

# How

We can't invalidate `mWrapperDelegateHolders` because view managers won't receive the correct app context. This variable memorizes and updates app context references in the view managers exported from Kotlin. 

That regression has been introduced in #19538. However, I don't think not clearing `mWrapperDelegateHolders` will affect the `Updates.reloadAsync` behavior.

# Test Plan

- bare-expo and NCL ✅
Kudo pushed a commit that referenced this pull request Nov 24, 2022
…loading on Android (#20063)

Closes #20033.

We can't invalidate `mWrapperDelegateHolders` because view managers won't receive the correct app context. This variable memorizes and updates app context references in the view managers exported from Kotlin.

That regression has been introduced in #19538. However, I don't think not clearing `mWrapperDelegateHolders` will affect the `Updates.reloadAsync` behavior.

- bare-expo and NCL ✅

(cherry picked from commit bd9b2b2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: suggestions ExpoBot has some suggestions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants