- 
                Notifications
    
You must be signed in to change notification settings  - Fork 24.9k
 
Do not handle JSI host object in deepFreezeAndThrowOnMutationInDev #27013
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
Conversation
| 
           Will this PR move onward?  | 
    
| 
           Any news on this ?  | 
    
| 
           Not sure if this   | 
    
| 
           @sota000 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.  | 
    
| 
           Hi @Kudo! I don't understand why we need two additional methods, can you clarify? instead of isHostObject and isHostFunction, would it be helpful to just have "isHostValue"? You should still be able to determine if it's a function or object by using  It's possible I'm mistaken but I believe you'd only need one additional method: isHostObject == typeof x === 'object' && !Array.isArray(x) && isHostValue(x)  | 
    
| 
           Instead of trying to precisely detect host objects, can we guard the   | 
    
| 
           the story is that hosted objects are not freezable.  | 
    
          
 Yes - my idea is to generalise that into "some objects are not freezable" and handle it in a standard, portable way, without adding new introspection APIs just for the JSI host object case.  | 
    
| 
           It sounds like that we don't have a strong use case for the utilities added in this PR due to 1. existence of the workaround and 2. no need for now to be precise when some objects are not freezable. If anyone wants to create a PR to add the error handling, but for now, I am closing this PR. Please re-open if you think this is still important. Thank you so much for the discussion!  | 
    
Summary
That is specific for react-native-v8 issue Kudo/react-native-v8#27, but I do think that V8 is semantic right and to introduce the change for RN upstream.
JSI host object is a JavaScript Object that C++ side could control getter or setter.
In react-native-v8, I use V8 object interceptor to implement JSI host object.
V8 does not allow
Object.freeze()for objects with interceptor and will throw exception.https://chromium.googlesource.com/v8/v8.git/+/lkgr/src/objects/js-objects.cc#3845
That is, you cannot truly freeze the JavaScript object because C++ side may add new properties in interceptor.
In this CL, I introduced some JSI helper functions to determine if the target object is JSI host object and skip the freezing.
Changelog
[General] [Changed] - Do not handle JSI host object in deepFreezeAndThrowOnMutationInDev
Test Plan
And see if there is JS exception.
That the returned value should be true.