-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 shared object leakage on android #25995
Conversation
packages/expo-modules-core/android/src/main/cpp/JavaScriptWeakObject.cpp
Outdated
Show resolved
Hide resolved
_weakObject = jsObject; | ||
_weakObjectType = WeakObjectType::NotSupported; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reality speaking, can that happen? We have some form of weak objects on all supported runtimes (JSC, Hermes, V8). Throwing an error rather than masking an unsupported operation is better. Otherwise, we may not notice something missing on new runtime in the future, causing massive leaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good question. in fact, on android, jsc supports jsi::WeakObject. it's just ios < 14.5 would go into this NonSupported flow.
on react-native 0.74, meta removed the flag and jsc should support jsi::WeakObject in all cases. maybe we can remove the logic for WeakRefAvailable/NonSupported here and use jsi::WeakObject for everything on android.
when we moved to 0.74, ios could remove the WeakRef code and align with android implementations. does that make sense to you?
ps. i didn't add jsi::WeakObject to v8 yet which i should. maybe it's good to update it in the christmas seasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave that as it is. We still want to make that code common, and I'm not a big fan of adding platform ifs. We can remove that logic later when we will be using 0.74.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i somehow changed my mind. since android supports jsi::WeakObject for all cases. i would go a step further to remove the WeakRef fallback code. ultimately on 0.74, ios will do the same removal and we don't need the shared WeakRef fallback code at all.
003741b
to
8f1a23f
Compare
# Why based on #25995 to integrate the new `deallocate()` in sqlite and fix the NativeStatementBinding leakage # How integrate `deallocate()` from `SharedObject` and cleanup jni data
# Why notice the shared objects have never been deallocated # How - introduce the `JavaScriptWeakObject` that is similar to what we had on ios and integrate to SharedObjectRegistry. - add a new `deallocate` method for a derived shared object to be notified when it is deallocated. # Test Plan test repro on https://github.com/ospfranco/expo-sqlite-benchmark (cherry picked from commit 6590dd0)
# Why notice the shared objects have never been deallocated # How - introduce the `JavaScriptWeakObject` that is similar to what we had on ios and integrate to SharedObjectRegistry. - add a new `deallocate` method for a derived shared object to be notified when it is deallocated. # Test Plan test repro on https://github.com/ospfranco/expo-sqlite-benchmark
# Why based on expo#25995 to integrate the new `deallocate()` in sqlite and fix the NativeStatementBinding leakage # How integrate `deallocate()` from `SharedObject` and cleanup jni data
Why
notice the shared objects have never been deallocated
How
JavaScriptWeakObject
that is similar to what we had on ios and integrate to SharedObjectRegistry.deallocate
method for derived shared object to be notified when it is deallocated.Test Plan
test repro on https://github.com/ospfranco/expo-sqlite-benchmark
Checklist
npx expo prebuild
& EAS Build (eg: updated a module plugin).