I got this error from Google Play Console, I cannot reproduce it and I didn’t call this class either:
Exception java.lang.RuntimeException: Can’t create handler inside thread Thread[Timer-0,5,main] that has not called Looper.prepare()
at android.os.Handler. (Handler.java:227)
at android.os.Handler. (Handler.java:129)
at com.rmsl.juce.JuceMidiSupport.handleDevicesChanged
at com.rmsl.juce.JuceMidiSupport.access$000 (JuceMidiSupport.java:63)
at com.rmsl.juce.JuceMidiSupport$MidiDeviceManager.onDeviceOpenedDelayed (JuceMidiSupport.java:948)
at com.rmsl.juce.JuceMidiSupport$MidiDeviceManager$MidiDeviceOpenTask.run (JuceMidiSupport.java:536)
at java.util.TimerThread.mainLoop (Timer.java:562)
at java.util.TimerThread.run (Timer.java:512)
If this related to initialiseJuce() or initialiseAllClasses() then I’ve make sure they are called on the main thread
That assert seems to be a message thread guard. What OS/version are you running on and do you have the complete stack trace of the assert, even if you don’t call the function yourself?
@Rincewind That’s the only message from log that I have. I’m on android 14. For now I’ve just commented the line that cause the crash, dont know if it works:
From the looks of it, this function is incorrectly called not on the message thread. I’m not terribly familiar with the android backend, but from the looks of it this is a JUCE bug where the native implementation of “handleDevicesChanged” is incorrectly not posting the change through the main event loop.
I’d try to wrap your removed line in MessageManager::callAsync. However, I’m not 100% sure if the java android side of things should make sure it executes that line on the message thread.
Thanks for reporting this issue. There was another similar issue that got patched recently:
I wonder whether you’ve tested on the latest version of JUCE to see whether this issue has been fixed there. If you’re still seeing problems, then I can take another look.