Skip to content

Commit 4ea0cc5

Browse files
kewdexwcandillon
andauthored
fix(jsi): resolve Symbol.dispose without JS eval (#3855)
JsiHostObject::get fell back to runtime.global().eval("Symbol.for('Symbol.dispose');") for the dispose-symbol lookup on every property miss. With a Hermes build that disables the JS eval builtin, the first miss throws an uncaught jsi::JSError and crashes the app on boot — reproducibly seen when Reanimated 4 worklets access `_isReanimatedSharedValue` on a Skia HostObject during MapperRegistry setup. Replace the eval invocation with a direct JSI traversal of `Symbol.for`. The behaviour is equivalent (Symbol.for("Symbol.dispose") returns the same well-known symbol regardless of how it is reached) and the path no longer depends on the JS eval builtin being available. Remove the now-unused `RNJsi::eval` helper (no other consumers in this file or across the package). Co-authored-by: William Candillon <wcandillon@gmail.com>
1 parent 5802477 commit 4ea0cc5

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

packages/skia/cpp/jsi/JsiHostObject.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ void JsiHostObject::set(jsi::Runtime &rt, const jsi::PropNameID &name,
2424
}
2525
}
2626

27-
jsi::Value eval(jsi::Runtime &runtime, const std::string &js) {
28-
return runtime.global()
29-
.getPropertyAsFunction(runtime, "eval")
30-
.call(runtime, js);
31-
}
32-
3327
jsi::Value JsiHostObject::get(jsi::Runtime &runtime,
3428
const jsi::PropNameID &name) {
3529
auto nameStr = name.utf8(runtime);
@@ -86,7 +80,11 @@ jsi::Value JsiHostObject::get(jsi::Runtime &runtime,
8680
// Check for dispose symbol as last resort
8781
static const auto disposeSymbol = jsi::PropNameID::forSymbol(
8882
runtime,
89-
eval(runtime, "Symbol.for('Symbol.dispose');").getSymbol(runtime));
83+
runtime.global()
84+
.getPropertyAsObject(runtime, "Symbol")
85+
.getPropertyAsFunction(runtime, "for")
86+
.call(runtime, "Symbol.dispose")
87+
.getSymbol(runtime));
9088
if (jsi::PropNameID::compare(runtime, disposeSymbol, name)) {
9189
// Recursively call get with "dispose" string
9290
auto disposeName = jsi::PropNameID::forAscii(runtime, "dispose");

0 commit comments

Comments
 (0)