Skip to content
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(android): Handle null value in setMenuCustomItems method #3375

Merged
merged 1 commit into from May 11, 2024

Conversation

m0ai
Copy link
Contributor

@m0ai m0ai commented Apr 2, 2024

Following the implementation of menuItems support in Android (#2993), there's been an observed issue within the Android platform where altering menuItems triggers a Null Pointer Exception.

This issue seems to originate from a missing null handling in RNCWebViewManagerImpl.kt. I've detailed the specific error encountered below for reference.

This PR introduces modifications to handle cases where value is null in the setMenuCustomItems function.

Your feedback is greatly appreciated.

    com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'menuItems' of a view managed by: RNCWebView
         at com.facebook.react.uimanager.v0$b.b(ViewManagerPropertyUpdater.java:123)
         at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:79)
         at com.facebook.react.uimanager.m.updateProperties(NativeViewHierarchyManager.java:15)
         at com.facebook.react.uimanager.r0$t.d(UIViewOperationQueue.java:9)
         at com.facebook.react.uimanager.p0.run(UIViewOperationQueue.java:132)
         at com.facebook.react.uimanager.r0.c(UIViewOperationQueue.java:54)
         at com.facebook.react.uimanager.r0$h.doFrameGuarded(UIViewOperationQueue.java:28)
         at com.facebook.react.uimanager.f.doFrame(GuardedFrameCallback.java:1)
         at com.facebook.react.modules.core.ReactChoreographer$b.doFrame(ReactChoreographer.java:36)
         at com.facebook.react.modules.core.a$a$a.doFrame(ChoreographerCompat.java:3)
         at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1299)
         at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1309)
         at android.view.Choreographer.doCallbacks(Choreographer.java:923)
         at android.view.Choreographer.doFrame(Choreographer.java:847)
         at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1283)
         at android.os.Handler.handleCallback(Handler.java:942)
         at android.os.Handler.dispatchMessage(Handler.java:99)
         at android.os.Looper.loopOnce(Looper.java:226)
         at android.os.Looper.loop(Looper.java:313)
         at android.app.ActivityThread.main(ActivityThread.java:8762)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
    Caused by: java.lang.reflect.InvocationTargetException
         at java.lang.reflect.Method.invoke(Native Method)
         at com.facebook.react.uimanager.v0$b.b(ViewManagerPropertyUpdater.java:65)
         at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:79) 
         at com.facebook.react.uimanager.m.updateProperties(NativeViewHierarchyManager.java:15) 
         at com.facebook.react.uimanager.r0$t.d(UIViewOperationQueue.java:9) 
         at com.facebook.react.uimanager.p0.run(UIViewOperationQueue.java:132) 
         at com.facebook.react.uimanager.r0.c(UIViewOperationQueue.java:54) 
         at com.facebook.react.uimanager.r0$h.doFrameGuarded(UIViewOperationQueue.java:28) 
         at com.facebook.react.uimanager.f.doFrame(GuardedFrameCallback.java:1) 
         at com.facebook.react.modules.core.ReactChoreographer$b.doFrame(ReactChoreographer.java:36) 
         at com.facebook.react.modules.core.a$a$a.doFrame(ChoreographerCompat.java:3) 
         at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1299) 
         at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1309) 
         at android.view.Choreographer.doCallbacks(Choreographer.java:923) 
         at android.view.Choreographer.doFrame(Choreographer.java:847) 
         at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1283) 
         at android.os.Handler.handleCallback(Handler.java:942) 
         at android.os.Handler.dispatchMessage(Handler.java:99) 
         at android.os.Looper.loopOnce(Looper.java:226) 
         at android.os.Looper.loop(Looper.java:313) 
         at android.app.ActivityThread.main(ActivityThread.java:8762) 
         at java.lang.reflect.Method.invoke(Native Method) 
         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604) 
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) 
    Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method com.reactnativecommunity.webview.RNCWebViewManager.setMenuCustomItems, parameter value
         at com.reactnativecommunity.webview.RNCWebViewManager.setMenuCustomItems(RNCWebViewManager.java:13)
         at java.lang.reflect.Method.invoke(Native Method) 

@TheAlmightyBob
Copy link
Collaborator

Looks like the Windows CI has generally started failing, unrelated to this or other PRs.

@Titozzz @chiaramooney Do you know anything about this?

@chiaramooney
Copy link
Collaborator

Hmm I'm about to be OOF, but I will take a look when I return.

@TheAlmightyBob TheAlmightyBob merged commit ccefcf1 into react-native-webview:master May 11, 2024
11 checks passed
react-native-community-bot pushed a commit that referenced this pull request May 11, 2024
## [13.10.1](v13.10.0...v13.10.1) (2024-05-11)

### Bug Fixes

* **android:** Handle null value in setMenuCustomItems method ([#3375](#3375)) ([ccefcf1](ccefcf1))
@react-native-community-bot
Copy link
Collaborator

🎉 This PR is included in version 13.10.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@m0ai
Copy link
Contributor Author

m0ai commented May 14, 2024

Thank you for reviewing and merging my pull request. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants