| Summary: | [Android] Opening Closing and Re-opening the same joystick fails | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Sylvain <sylvain.becker> |
| Component: | joystick | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | philipp.wiesemann |
| Version: | 2.0.4 | ||
| Hardware: | All | ||
| OS: | Android (All) | ||
|
Description
Sylvain
2016-08-15 21:47:36 UTC
step to reproduce the isse:
case SDL_JOYDEVICEADDED:
int which = evt.jdevice.which;
SDL_Joystick *joystick;
// Open: ok
joystick = SDL_JoystickOpen(which);
if (joystick == NULL) {
return;
}
// Close: ok
SDL_JoystickClose(joystick);
// Re-open: fails on Android with error "Joystick already opened".
joystick = SDL_JoystickOpen(which);
if (joystick == NULL) {
return;
}
I can not test this now but maybe it can be fixed by changing SDL_SYS_JoystickClose() in "src/joystick/android/SDL_sysjoystick.c" to:
void
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
{
SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
item->joystick = NULL;
}
Thanks! I have tested the patch and it fixes the issue. This bug was fixed here: https://hg.libsdl.org/SDL/rev/3501018c6df2 And it was fixed for Emscripten here: https://hg.libsdl.org/SDL/rev/ba7dc3ebb81e Thanks! Thanks for the fast help! By the way, you fixed it:) I just reported it ! It seems to work for most of the cases, but I got this stack trace on Android Developer Console. Only one, after thousands of updates.
According to the code, that happened after receiving a "SDL_JOYDEVICEREMOVED".
... I would add a safe check :)
SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
+ if (item) {
item->joystick = NULL
+ }
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/hltexx/hlte:5.0/LRX21V/N9005XXUGBOK6:user/release-keys'
Revision: '8'
ABI: 'arm'
pid: 26152, tid: 26216, name: SDLThread >>> net.jeu.myapp <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20
r0 00000000 r1 00000000 r2 00000003 r3 b6edc004
r4 937fce40 r5 951c5270 r6 00000000 r7 951c4090
r8 00000000 r9 ffffffff sl 951c4098 fp 00000000
ip b46a5a30 sp 951c4088 lr b464b715 pc b464c5c0 cpsr 40070030
backtrace:
#00 pc 000485c0 /data/app/net.jeu.myapp-1/lib/arm/libSDL2.so (SDL_SYS_JoystickClose+3)
#01 pc 00047711 /data/app/net.jeu.myapp-1/lib/arm/libSDL2.so (SDL_JoystickClose_REAL+28)
#03 pc 0006bca3 /data/app/net.jeu.myapp-1/lib/arm/libmain.so (pollEvent(int*)+826)
This patch is now https://hg.libsdl.org/SDL/rev/74c39dbe8d30 (and https://hg.libsdl.org/SDL/rev/d1c27f616999), thanks! |