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

java.lang.IllegalStateException: Should be called from the main thread, not Thread[mqt_native_modules #423

Open
SudoPlz opened this issue Sep 27, 2021 · 2 comments

Comments

@SudoPlz
Copy link
Contributor

SudoPlz commented Sep 27, 2021

Hey friends,

I get this in production:

java.lang.IllegalStateException: Should be called from the main thread, not Thread[mqt_native_modules,5,main]
  at curtains.internal.HandlersKt.checkMainThread (Handlers.kt:9)
  at curtains.WindowsKt.getWindowType (Windows.kt:37)
  at shadow.leakcanary.RootViewWatcher$listener$1.onRootViewAdded (RootViewWatcher.kt:44)
  at curtains.OnRootViewAddedListener$DefaultImpls.onRootViewsChanged (Listeners.kt:37)
  at shadow.leakcanary.RootViewWatcher$listener$1.onRootViewsChanged (RootViewWatcher.kt:43)
  at curtains.internal.RootViewsSpy$delegatingViewList$1.add (RootViewsSpy.kt:25)
  at curtains.internal.RootViewsSpy$delegatingViewList$1.add (RootViewsSpy.kt:23)
  at android.view.WindowManagerGlobal.addView (WindowManagerGlobal.java:454)
  at android.view.WindowManagerImpl.addView (WindowManagerImpl.java:114)
  at android.app.Dialog.show (Dialog.java:505)
  at com.beefe.picker.PickerViewModule.show (PickerViewModule.java:441)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:151)
  at com.facebook.react.bridge.queue.NativeRunnable.run (Native Method)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
  at android.os.Looper.loop (Looper.java:246)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:226)
  at java.lang.Thread.run (Thread.java:923)

Any idea how to fix it?

I already tried:

+++ b/node_modules/react-native-picker/android/src/main/java/com/beefe/picker/PickerViewModule.java
@@ -6,7 +6,9 @@ import android.app.Dialog;
 import android.graphics.Color;
 import android.graphics.PixelFormat;
 import android.graphics.Typeface;
-import android.support.annotation.Nullable;
+
+import androidx.annotation.MainThread;
+import androidx.annotation.Nullable;
 import android.text.TextUtils;
 import android.view.Gravity;
 import android.view.View;
@@ -429,6 +431,7 @@ public class PickerViewModule extends ReactContextBaseJavaModule implements Life
         select(selectedValue);
     }
 
+    @MainThread
     @ReactMethod
     public void show() {
         if (dialog == null) {
@@ -439,6 +442,7 @@ public class PickerViewModule extends ReactContextBaseJavaModule implements Life
         }
     }
 
+    @MainThread
     @ReactMethod
     public void hide() {
         if (dialog == null) {

but this didn't work.

@Nashmod
Copy link

Nashmod commented Jul 8, 2022

Did you ever manage to fix this?

@one-god
Copy link

one-god commented May 19, 2023

same issue with

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

No branches or pull requests

3 participants