question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Controller listener + LwjglFrame causes crash

See original GitHub issue

Issue details

While controllers are connected, attempting to add a controller listener in an app that also uses a LwjglFrame causes the error:

Error creating joystick: Win32JoyStick::_initialize() >> failed to set cooperation level!
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000621c3e13, pid=31304, tid=0x00000000000027f4
#
# JRE version: Java(TM) SE Runtime Environment (8.0_141-b15) (build 1.8.0_141-b15)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.141-b15 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [gdx-controllers-desktop64.dll+0x3e13]

Reproduction steps/code

It’s a little hard to isolate the code in my engine, but in a default project, start your game this way: new LwjglFrame(new MyGDXGame(), cfg); //the configuration doesn't matter

At some point in your game’s code, attempt to add a controller listener. Controllers.addListener(my_controller_listener);

The app will crash at this point with the above error if any controllers are connected. Unplugging the controllers before starting the app will cause the app to work properly.

If you start your game using LwjglApplication instead of LwjglFrame, it will start normally with no other changes necessary: new LwjglApplication(new MyGDXGame(), cfg);

Version of LibGDX and/or relevant dependencies

1.9.10. It may affect earlier versions but I’m not sure.

Stacktrace

Have to type this myself as it doesn’t print out anywhere. I stepped through the GDX sources, and it crashes at OisJoystick.getButtonCount. The joystickPtr value of the OisJoystick is 0, which seems to me like it might be an invalid value but I’m not sure.

OisJoystick.getButtonCount() line: 91
OisJoystick.<init>(long, String) line: 40
Ois.<init>(long) line: 33
OisControllers.<init>(DesktopControllerManager) line: 44
DesktopControllerManager.<init>() line: 32
NativeConstructorAccessorImpl.newInstance()(Constructor<?>, Object[]) line: not available [native method]
NativeConstructorAccessorImpl.newInstance(Object[]) line: not available
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: not available
Constructor<T>.newInstance(Object...) line: not available
Class<T>.newInstance() line: not available
ClassReflection.newInstance(Class<T>) line: 93
Controllers.initialize() line: 118
Controllers.addListener(ControllerListener) line: 59

Please select the affected platforms

  • Android
  • iOS (robovm)
  • iOS (MOE)
  • HTML/GWT
  • Windows
  • Linux
  • MacOS

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
Schyfiscommented, Dec 31, 2019

As an alternative, you can use the Jamepad implementation. I would recommend it for Lwjgl2 anyway because it supports hotplugging.

Just wanted to update- I did end up moving to Jamepad. I’m very happy with it so far, and moving to it was painless. Rumble support and hotplugging is awesome, and I’d second your recommendation to use Jamepad for anyone running into this issue.

0reactions
MrStahlfelgecommented, Sep 15, 2020

Hi, please take a look at gdx-controllers v2 prerelease snapshot. It’s powered by Jamepad.

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS16 autofill causes crash while … | Apple Developer Forums
Same issue , I encountered in iOS 16.1.0 Here is detail logs. Application tried to present modally a view controller <_SFAppAutoFillPasswordViewController: ...
Read more >
5 Troubleshoot System Crashes
A crash, or fatal error, causes a process to terminate abnormally. There are various possible reasons for a crash. For example, a crash...
Read more >
Detect and diagnose 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 >
Third-party MAXScript (ALC) causes crashes, corruption, gives ...
When opening or working with a 3ds Max file (*.max), the scene file crashes, corrupts scene data, gives a Script Controller error or...
Read more >
App crashing after implementing Firebase Auth listener in ...
Resolved: The crash was causing by a memory leaks due to a strong reference cycle. here is a great tutorial to understand it: ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found