[Android] App crash when onCancel is fired a lot of times
See original GitHub issueHello,
I might have a little problem with this code (at least, I think):
/**
* override onCancel method to callback cancel in case of a touch
* outside of the dialog or the BACK key pressed
*/
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
dialog.dismiss();
response.putBoolean("didCancel", true);
callback.invoke(response);
}
});
which could cause this error when I click at multiples times outside the popup:
03-09 17:08:12.354 2798-5915/com.mycompany.myapp E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: com.mycompany.myapp, PID: 2798
com.facebook.react.bridge.ObjectAlreadyConsumedException: Receiving map already consumed
at com.facebook.react.bridge.WritableNativeMap.putBoolean(Native Method)
at com.imagepicker.ImagePickerModule$2.onCancel(ImagePickerModule.java:141)
at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1326)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:185)
at java.lang.Thread.run(Thread.java:818)
03-09 17:08:12.481 2798-2798/com.mycompany.myapp I/TSLocationManager: - RNBackgroundGeolocationModule#destroy
03-09 17:08:12.526 2798-2809/com.mycompany.myapp W/MessageQueue: Handler (android.view.ViewRootImpl$ViewRootHandler) {52ab619} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.view.ViewRootImpl$ViewRootHandler) {52ab619} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
at android.os.Handler.enqueueMessage(Handler.java:631)
at android.os.Handler.sendMessageAtTime(Handler.java:600)
at android.os.Handler.sendMessageDelayed(Handler.java:570)
at android.os.Handler.sendEmptyMessageDelayed(Handler.java:534)
at android.os.Handler.sendEmptyMessage(Handler.java:519)
at android.view.ViewRootImpl.dispatchWindowAnimationStopped(ViewRootImpl.java:6273)
at android.view.ViewRootImpl$W.onAnimationStopped(ViewRootImpl.java:6842)
at android.view.IWindow$Stub.onTransact(IWindow.java:244)
at android.os.Binder.execTransact(Binder.java:453)
03-09 17:08:12.550 2798-2811/com.mycompany.myapp W/MessageQueue: Handler (android.view.ViewRootImpl$ViewRootHandler) {52ab619} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.view.ViewRootImpl$ViewRootHandler) {52ab619} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
at android.os.Handler.enqueueMessage(Handler.java:631)
at android.os.Handler.sendMessageAtTime(Handler.java:600)
at android.os.Handler.sendMessageDelayed(Handler.java:570)
at android.os.Handler.sendMessage(Handler.java:507)
at android.view.ViewRootImpl.windowFocusChanged(ViewRootImpl.java:6231)
at android.view.ViewRootImpl$W.windowFocusChanged(ViewRootImpl.java:6736)
at android.view.IWindow$Stub.onTransact(IWindow.java:156)
at android.os.Binder.execTransact(Binder.java:453)
03-09 17:08:12.636 2798-2809/com.mycompany.myapp W/MessageQueue: Handler (android.view.ViewRootImpl$ViewRootHandler) {52ab619} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.view.ViewRootImpl$ViewRootHandler) {52ab619} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
at android.os.Handler.enqueueMessage(Handler.java:631)
at android.os.Handler.sendMessageAtTime(Handler.java:600)
at android.os.Handler.sendMessageDelayed(Handler.java:570)
at android.os.Handler.sendMessage(Handler.java:507)
at android.view.ViewRootImpl.dispatchAppVisibility(ViewRootImpl.java:6218)
at android.view.ViewRootImpl$W.dispatchAppVisibility(ViewRootImpl.java:6720)
at android.view.IWindow$Stub.onTransact(IWindow.java:140)
at android.os.Binder.execTransact(Binder.java:453)
03-09 17:08:12.652 2798-2811/com.mycompany.myapp W/MessageQueue: Handler (android.view.ViewRootImpl$ViewRootHandler) {52ab619} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.view.ViewRootImpl$ViewRootHandler) {52ab619} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
at android.os.Handler.enqueueMessage(Handler.java:631)
at android.os.Handler.sendMessageAtTime(Handler.java:600)
at android.os.Handler.sendMessageDelayed(Handler.java:570)
at android.os.Handler.sendMessage(Handler.java:507)
at android.os.Message.sendToTarget(Message.java:416)
at android.view.ViewRootImpl.dispatchWindowAnimationStarted(ViewRootImpl.java:6268)
at android.view.ViewRootImpl$W.onAnimationStarted(ViewRootImpl.java:6834)
at android.view.IWindow$Stub.onTransact(IWindow.java:238)
at android.os.Binder.execTransact(Binder.java:453)
03-09 17:08:13.053 2798-5884/com.mycompany.myapp W/MessageQueue: Handler (android.view.ViewRootImpl$ViewRootHandler) {52ab619} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.view.ViewRootImpl$ViewRootHandler) {52ab619} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
at android.os.Handler.enqueueMessage(Handler.java:631)
at android.os.Handler.sendMessageAtTime(Handler.java:600)
at android.os.Handler.sendMessageDelayed(Handler.java:570)
at android.os.Handler.sendEmptyMessageDelayed(Handler.java:534)
at android.os.Handler.sendEmptyMessage(Handler.java:519)
at android.view.ViewRootImpl.dispatchWindowAnimationStopped(ViewRootImpl.java:6273)
at android.view.ViewRootImpl$W.onAnimationStopped(ViewRootImpl.java:6842)
at android.view.IWindow$Stub.onTransact(IWindow.java:244)
at android.os.Binder.execTransact(Binder.java:453)
Do you have an idea of what’s can cause that? Thanks!
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Why do my apps keep crashing on Android, How to fix it
There can be multiple ways in which you can fix an app that keeps crashing on your Android smartphone. 1. Force stop the...
Read more >App crash after sending message to Firebase Database?
Hi @AhsanUllahRasel yes, the problem with this situation is, previously, sending messages was fine until there was one time an emoji was sent ......
Read more >Crashes | Android Developers
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java...
Read more >Why Do My Apps Keep Crashing on Android? - Avast
This article contains: Why are apps on my Android crashing? How to stop apps from crashing; Avoid annoying app crashes with Avast Cleanup....
Read more >Help AARP Combat Medicare Fraud - aslanpelet.com
Find more information on . Cancel You are leaving AARP.org and going to the ... iGesShop La App de compra pe APK Download...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This happened to me when i was trying to push the same map to a WritableArray twice by mistake in a loop.
for eg.
Bad code:
The code should have been:
As you can see in the bad example, the variable
map
was not inside the loop and wasnt being recreated on each iteration so it had the same reference.It seems the WritableArray is aware of the references of the objects and doesn’t allow you to add a map twice.
hope this helps or gives some insight
I just made a little update in the project to fix this. As @lwhiteley just tell. Hope this will fix the issue !
https://github.com/marcshilling/react-native-image-picker/commit/f134b9158cb29144fc12f9112f690c0bdef8ea79#diff-e2ac0feb8ce151bd872a7c4ab6b4801dR170