MobiVM / robovm

Ahead of time compiler for JVM bytecode targetting iOS, Mac OSX and Linux
https://mobivm.github.io
963 stars 133 forks source link

NSThread.exit(); causes a crash. #197

Closed piotr-j closed 5 years ago

piotr-j commented 7 years ago

Issue details

Calling Gdx.app.exit() (NSThread.exit();) causes a crash.

Configuration

Happens with launchIOSDevice task, on Iphone 6s, 10.3.3

Build Tools:

Versions:

Stacktrace

Cannot detach thread when there are non native frames on the call stack

The crash logs fails to resymbolicate the app methods, so its not very useful.

keesvandieren commented 7 years ago

Apple will reject apps in their review process, that call Gdx.app.exit(). Not sure whether it is useful to not crash on that method?

In some of our apps, we have integrated Crashlytics (including Symbol uploading of the IPA deployed to App Store) We see the method names of our Kotlin classes and of the Libgdx classes as well.

Are you using Crashlytics?

Than you need to upload the Symbols to Crashlytics. Example in Gradle:

task uploadSymbols(type:Exec) {
    commandLine '/Applications/Fabric.app/Contents/MacOS/upload-symbols',
            '-a', '867d492b6dfabric-id-here', '-p', 'ios', './build/robovm/appname.app.dSYM/'
}
gagbaghdas commented 5 years ago

@keesvandieren I have the same problem and have the stacktrace from the crashlytics.

Crashed: com.apple.main-thread
0  libsystem_c.dylib              0x1b7bcff6c __abort + 184
1  libsystem_c.dylib              0x1b7bcfeb4 __abort + 150
2  IsoGameLauncher                0x101711f94 (Missing)
3  IsoGameLauncher                0x101720d3c (Missing)
4  IsoGameLauncher                0x101720988 (Missing)
5  libsystem_pthread.dylib        0x1b7cfb468 _pthread_tsd_cleanup + 504
6  libsystem_pthread.dylib        0x1b7cf8904 _pthread_exit + 80
7  libsystem_pthread.dylib        0x1b7cede54 pthread_exit + 36
8  Foundation                     0x1b8a6b8a4 +[NSNotificationCenter _defaultCenterWithoutCreating] + 14
9  IsoGameLauncher                0x10122811c (Missing)
10 IsoGameLauncher                0x101226468 (Missing)
11 IsoGameLauncher                0x101225bc0 (Missing)
12 IsoGameLauncher                0x1005fae90 [J]com.badlogic.gdx.backends.iosrobovm.IOSApplication.exit()V (IOSApplication.java:444)
13 IsoGameLauncher                0x100a6a588 [J]com.frismos.olympusgame2.util.CrossPlatformUtilsIOSImpl.exitGame()V (CrossPlatformUtilsIOSImpl.java:94)
14 IsoGameLauncher                0x100a7bf34 [J]com.frismos.olympusgame2.util.Utils$5.touchUp(Lcom/badlogic/gdx/scenes/scene2d/InputEvent;FFII)V (Utils$5.java:320)
15 IsoGameLauncher                0x1007502b8 [J]com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener.handle(Lcom/badlogic/gdx/scenes/scene2d/Event;)Z (ActorGestureListener.java:118)
16 IsoGameLauncher                0x10070e408 [J]com.badlogic.gdx.scenes.scene2d.Stage.touchUp(IIII)Z (Stage.java:351)
17 IsoGameLauncher                0x1005e6e30 [J]com.badlogic.gdx.InputMultiplexer.touchUp(IIII)Z (InputMultiplexer.java:124)
18 IsoGameLauncher                0x10060bea4 [J]com.badlogic.gdx.backends.iosrobovm.IOSInput.processEvents()V (IOSInput.java:630)
19 IsoGameLauncher                0x100608a5c [J]com.badlogic.gdx.backends.iosrobovm.IOSGraphics.draw(Lorg/robovm/apple/glkit/GLKView;Lorg/robovm/apple/coregraphics/CGRect;)V (IOSGraphics.java:348)
20 IsoGameLauncher                0x1006099a4 [J]com.badlogic.gdx.backends.iosrobovm.IOSGraphics$1.draw(Lorg/robovm/apple/coregraphics/CGRect;)V (IOSGraphics$1.java:225)
21 IsoGameLauncher                0x100609a9c (Missing)
22 IsoGameLauncher                0x100609800 (Missing)
23 IsoGameLauncher                0x10060987c (Missing)
24 GLKit                          0x1c4ff691c -[GLKView _display:] + 256
25 GLKit                          0x1c4ff7b24 -[GLKViewController _updateAndDraw] + 520
26 QuartzCore                     0x1bc43a194 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 636
27 IOKit                          0x1b8334718 IODispatchCalloutFromCFMessage + 488
28 CoreFoundation                 0x1b8043d30 __CFMachPortPerform + 188
29 CoreFoundation                 0x1b806a934 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
30 CoreFoundation                 0x1b806a080 __CFRunLoopDoSource1 + 440
31 CoreFoundation                 0x1b8064ea4 __CFRunLoopRun + 2096
32 CoreFoundation                 0x1b8064354 CFRunLoopRunSpecific + 436
33 GraphicsServices               0x1ba26479c GSEventRunModal + 104
34 UIKitCore                      0x1e461bb68 UIApplicationMain + 212
35 IsoGameLauncher                0x10142dd08 (Missing)
36 IsoGameLauncher                0x10142d0c0 [J]org.robovm.apple.uikit.UIApplication.main([Ljava/lang/String;Ljava/lang/Class;Ljava/lang/Class;)V (UIApplication.java:428)
37 IsoGameLauncher                0x10142c1a0 (Missing)
38 IsoGameLauncher                0x1008014e4 [J]com.frismos.olympusgame2.IsoGameLauncher.main([Ljava/lang/String;)V (IsoGameLauncher.java:86)
39 IsoGameLauncher                0x1017221e0 (Missing)
40 IsoGameLauncher                0x101717e68 (Missing)
41 IsoGameLauncher                0x10171a6c0 (Missing)
42 IsoGameLauncher                0x10171a754 (Missing)
43 IsoGameLauncher                0x101712820 (Missing)
44 IsoGameLauncher                0x101707fc4 (Missing)
45 libdyld.dylib                  0x1b7b2a8e0 start + 4
dkimitsa commented 5 years ago

it is up to design. you can't terminate main thread this way. it is being crashed by RoboVM itself. as it contains native frames. E.g.

main() // java UIApplication.main(args, null, Main.class); // native NSThread.exit(). // java

You have to exit from thread gracefully. Same reason java Thread.stop() is throwing UnsupportedOperationException and marked as deprecated.

keesvandieren commented 5 years ago

I think we can close this issue? As it is clearly not a bug.

gagbaghdas commented 5 years ago

Yup @keesvandieren.

Just for the clarification of the result.

Do not make an exit button in your app. )

keesvandieren commented 5 years ago

@piotr-j please close issue