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

Handle invalid parent view #144

Merged
merged 3 commits into from
Jun 28, 2020
Merged

Handle invalid parent view #144

merged 3 commits into from
Jun 28, 2020

Conversation

sudendrakl
Copy link
Contributor

@sudendrakl sudendrakl commented Feb 19, 2020

Takes care of this crash

Fatal Exception: java.lang.IllegalArgumentException: No suitable parent found from the given view. Please provide a valid view.
       at android.support.design.widget.Snackbar.make(Snackbar.java:181)
       at com.azendoo.reactnativesnackbar.SnackbarModule.displaySnackbar(SnackbarModule.java:93)
       at com.azendoo.reactnativesnackbar.SnackbarModule.show(SnackbarModule.java:69)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
       at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
       at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
       at android.os.Looper.loop(Looper.java:193)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
       at java.lang.Thread.run(Thread.java:764)

Resolves #97

Takes care of this crash
```
Fatal Exception: java.lang.IllegalArgumentException: No suitable parent found from the given view. Please provide a valid view.
       at android.support.design.widget.Snackbar.make(Snackbar.java:181)
       at com.azendoo.reactnativesnackbar.SnackbarModule.displaySnackbar(SnackbarModule.java:93)
       at com.azendoo.reactnativesnackbar.SnackbarModule.show(SnackbarModule.java:69)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
       at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
       at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
       at android.os.Looper.loop(Looper.java:193)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
       at java.lang.Thread.run(Thread.java:764)
```
@cooperka
Copy link
Owner

Thanks for the submission @sudendrakl. I'd prefer a more targeted solution so that other unrelated errors aren't swallowed up -- do you know which line of code was causing the IllegalArgumentException for you? The stack trace shows displaySnackbar(SnackbarModule.java:93) but I'm not sure which version you're on.

@sudendrakl
Copy link
Contributor Author

@cooperka missed your reply
Anyway this line ArrayList<View> modals = recursiveLoopChildren(view, new ArrayList<View>());

modals can be in busy state doing some drawing or some stuff and not be available for snackbar to use, so this IllegalArgument happens

@cooperka
Copy link
Owner

I've made the solution here more targetted; it would still be nice to track down the root cause but at least this situation won't crash anymore.

@cooperka cooperka merged commit 2fb9270 into cooperka:master Jun 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fatal Exception: java.lang.IllegalArgumentException
2 participants