Closed mrousavy closed 1 week ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
This code here works:
and this code here crashes:
..same as if I would just not call hasNativeState
at all, this also crashes:
So what makes it work? The assert(..)
can't be hit, can it? It would crash the app...
Okay some more insights:
auto nativeState = object.getNativeState(runtime);
object.hasNativeState(runtime);
auto nativeState = object.getNativeState(runtime);
if (!object.hasNativeState(runtime)) {
assert(false);
}
auto nativeState = object.getNativeState(runtime);
if (!object.hasNativeState(runtime)) {
value.toString(runtime);
}
auto nativeState = object.getNativeState(runtime);
So maybe the object
is somehow flattened or lazy evaluated in a sense that NativeState
isn't properly available?
I am still kinda baffled that the assert
does not crash the app, maybe object.hasNativeState(...)
is not the same as the internal assert of object.getNativeState(...)
?
cc @hannojg @tmikov
Created an issue in the Hermes repo for now: https://github.com/facebook/hermes/issues/1564
I think this can be fixed by just adjusting the code in the example app. No need to slow down all function calls for users by leaving this check in release builds
I honestly don't know why this crashes.
But now we check for
hasNativeState()
also in release builds, not only debug. This will thenthrow
if the function is called on an unbound object (nothis
/NativeState
).I can only explain this being called by
console.log
'ing an unbound object (so just the Prototype) - which has an overriddentoString
function but that requires it to be bound. I guess ifconsole.log
callstoString()
andtoString()
throws, it will catch the error internally.. idk man.no real production app will call
toString()
on a prototype in release, so I'm not sure if this is the right approach.