MacOS crashes on Controllers.getControllers()
It works fine on Linux, Android, etc. But for some reason, when it gets to this specific line in MacOS, the program hangs. Controllers.getControllers() I've proven this with debug statements.
It doesn't matter if I have a controller connected via USB, paired with bluetooth (and working in another game), or no controller at all. Same result.
I'm on the "latest" 2.2.3 gdx-controllers. Yes, I put it in quotes, because it's 1.3 years old, and I noticed at least 2 commits since the 2.2.3 release which could affect this.
Using the latest LibGDX as well. 1.12.1
The lib uses Jamepad internally, maybe try to use a newer version.
So you mean fork this repo and make that upgrade to the Jamepad library, publish my forked version to Maven or something, and then include that in my Android LibGDX project instead of gdx-controllers?
No; see "Installation" on the main readme page
Ok, I have the following versions gdxControllersVersion=2.2.4-SNAPSHOT jamepadVersion=2.26.4.0 gdxVersion=1.12.1
And I updated my Desktop build gradle: dependencies { implementation project(':core') implementation "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" implementation "com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion" implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop" implementation("com.badlogicgames.jamepad:jamepad:$jamepadVersion") { exclude group: 'com.badlogicgames.gdx', module: 'gdx-jnigen-loader' } }
Still having the same lock-up issue. The program freezes at Controllers.getControllers(), but only on MacOS desktop.
Could you try to get a stack trace while the program is hanging? VisualVM or a similar program should let you do that.
WHILE the program is hanging? That sounds like Logcat. If this were Android, I'd check the Logcat output with a crash like this. But is there such an equivalent on MacOS? I don't have VisualVM. Is that free? (This is a hobby project, not a commercial company with a budget to purchase software) What do VisualVM and similar programs do? Give you details about a crash when a non-debug executable is running?
VisualVM is a Java profiler. It's a free download, and at one point was even packaged with the JDK. It runs as its own application, displays a list of java applications that are running. You can click on one to start monitoring it, and it will show you various information about what the program is doing. In the Threads tab, there is a button labeled "Thread Dump" that will give you a stack trace of your threads.
Download page: https://visualvm.github.io/ Documentation: https://docs.oracle.com/javase/8/docs/technotes/guides/visualvm/ Page that explains Thread Dump: https://docs.oracle.com/javase/8/docs/technotes/guides/visualvm/threads.html
I am also seeing a crash when calling Controllers.getControllers() on iOS. I do not see this on Windows, MacOS, or Linux.
What I've tried:
- Simulator & Device
- Jamepad versions 2.30.0.0 and 2.26.5.0
How to repro:
- Use gdx liftoff create a new ios project with controllers.
- Add
Array<Controller> controllers = Controllers.getControllers();to create() - Attempt to launch app
Stack trace
$ ./gradlew ios:launchIPhoneSimulator
objc[71545]: Class _NoAnimationDelegate is implemented in both /Library/Developer/CoreSimulator/Volumes/iOS_23A343/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 26.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore (0x143840130) and /Library/Developer/CoreSimulator/Volumes/iOS_23A343/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 26.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore (0x1409a9198). This may cause spurious casting failures and mysterious crashes. One of the duplicates must be removed or renamed.
/Users/joshua/Desktop/ios-libgdx/ios/build/robovm.tmp/IOSLauncher.app/Frameworks/gdx.framework: replacing existing signature
/Users/joshua/Desktop/ios-libgdx/ios/build/robovm.tmp/IOSLauncher.app/Frameworks/ObjectAL.framework: replacing existing signature
/Users/joshua/Desktop/ios-libgdx/ios/build/robovm.tmp/IOSLauncher.app: replacing existing signature
2025-10-09 15:17:54.692 IOSLauncher[71587:96624455] [debug] IOSApplication: iOS version: 26.0
2025-10-09 15:17:54.692 IOSLauncher[71587:96624455] [debug] IOSApplication: Running in 64-bit mode
2025-10-09 15:17:54.698 IOSLauncher[71587:96624455] [debug] IOSApplication: Pixels per point: 3.0
2025-10-09 15:17:54.719 IOSLauncher[71587:96624455] [debug] IOSApplication: Status bar is not visible
2025-10-09 15:17:54.719 IOSLauncher[71587:96624455] [debug] IOSApplication: Computed bounds are x=0 y=0 w=390 h=844 bbW= 1170 bbH= 2532
2025-10-09 15:17:54.751 IOSLauncher[71587:96624455] [debug] IOSGraphics: Display: ppi=264, density=1.65
2025-10-09 15:17:54.878 IOSLauncher[71587:96624455] [debug] IOSApplication: created
2025-10-09 15:17:54.883 IOSLauncher[71587:96624455] [info] Controllers: added manager for application, 1 managers active
java.lang.NoSuchMethodError: org.robovm.apple.gamecontroller.GCController$Notifications.observeDidConnect(Lorg/robovm/objc/block/VoidBlock1;)Lorg/robovm/apple/foundation/NSObjectProtocol;
at com.badlogic.gdx.controllers.IosControllerManager.initializeControllerArray(IosControllerManager.java:86)
at com.badlogic.gdx.controllers.IosControllerManager.getControllers(IosControllerManager.java:65)
at com.badlogic.gdx.controllers.Controllers.getControllers(Controllers.java:48)
at com.interrupt.dungeoneer.GameApplication.create(GameApplication.java:23)
at com.badlogic.gdx.backends.iosrobovm.IOSApplication.didFinishLaunching(IOSApplication.java:160)
at com.badlogic.gdx.backends.iosrobovm.IOSApplication$Delegate.didFinishLaunching(IOSApplication.java:63)
at com.badlogic.gdx.backends.iosrobovm.IOSApplication$Delegate.$cb$application$didFinishLaunchingWithOptions$(IOSApplication.java)
at org.robovm.apple.uikit.UIApplication.main(Native Method)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java:442)
at com.interrupt.dungeoneer.IOSLauncher.main(IOSLauncher.java:20)
com.interrupt.dungeoneer.DelverTest2: 71587
Edit 2025-10-11 I'm wondering if this is a RoboVM/MobiVM issue? I was using XCode 24 and I downgraded as far as my M2 MacBook would let me (XCode 16) and I'm still getting the NoSuchMethodError.