-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix "Not implemented" exception on JSC #6028
base: main
Are you sure you want to change the base?
Conversation
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.
Why can't we just call hasNativeState
in try/catch
block?
@tomekzaw It's for performance. Why would we surround it with the try-catch on every call, since we will know everything after the first call. |
@tjzel I wouldn't worry much about performance in this case, C++ SInce we know that some versions react-native-macos don't support Also, the names Finally, I don't like the fact that some unrelated files have been formatted, can we move them to a separate PR? |
Sorry about that, I added |
@mrousavy No worries |
@tomekzaw I read an interesting article about try/catch blocks performance from which it seems that try blocks are fast but the catch ones are expensive. Since these calls would constantly throw when Regarding I'll revert formatting and make the names more approachable. |
void ShareableObject::runWithNativeStateProbe( | ||
std::function<void()> &&block) { | ||
try { | ||
block(); |
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.
Why we need to pass an lambda here instead of just execute obj.setNativeState(rt, nativeState_);
?
try { | ||
block(); | ||
isNativeStateImplemented_ = IsNativeStateImplemented::Yes; | ||
} catch (...) { |
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.
Does this 'Not implemented' exception have a specific type that we can implicitly catch here?
Summary
In some implementations of JSC, at least
react-native-macos
here native state methods are not implemented and they are throwing errors. This PR adds logic that will go around this issue, by probing thehasNativeState
method to determine whether it should use that.Fixes #5974
Test plan