Skip to content

Commit

Permalink
fix: Remove dangling global reference to ScreenModule (#2494)
Browse files Browse the repository at this point in the history
## Description

Removes a dangling global reference to the `ScreenModule`.

## Changes

When the application reloads, `nativeInstall` is called, which
overwrites the reference to `globalThis` without deleting it. This PR
deletes the reference before creating a new one.

## Test code and steps to reproduce

I've tested it in a new project created using expo (SDK 52) and with
fabric turn on.
  • Loading branch information
lukmccall authored Nov 12, 2024
1 parent fa51b58 commit b84fd63
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions android/src/main/cpp/jni-adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Java_com_swmansion_rnscreens_ScreensModule_nativeInstall(
return;
}
jsi::Runtime &rt = *runtime;
if (globalThis) {
env->DeleteGlobalRef(globalThis);
}
globalThis = env->NewGlobalRef(thiz);
JavaVM *jvm;
env->GetJavaVM(&jvm);
Expand Down

0 comments on commit b84fd63

Please sign in to comment.