flowkey / UIKit-cross-platform

Cross-platform Swift implementation of UIKit, mostly for Android
MIT License
600 stars 40 forks source link

Fix a lot of crashes (and blank screens!) when minimizing and restoring #193

Closed ephemer closed 6 years ago

ephemer commented 6 years ago

Fixes #162 Fixes https://github.com/flowkey/NativePlayerIOS/issues/414 Fixes https://github.com/flowkey/smartphone-app/issues/973

Type of change: Bugfix

Motivation

The player crashes all the time when loading and leaving, minimising, gaining / losing focus etc. This fixes almost all of them on the tested device (careful: only one!), at least for the player test app. We may need to make similar changes for the PlayerViewManager but that should be manageable 🥁🥁🥁....

What we'd like to do in the future is have the player context restore a little more gracefully: it shouldn't be necessary to destroy everything and start over, but first things first ;)

cshg commented 6 years ago

Awesome! 💪 🎉 Let's test this intensively and see if it really fixes all those crashes. If it does that's really a huge improvement! Congrats 😊 As you mentioned before @ephemer we should still try to keep PRs here as generic for UIKit as possible and not mention too many references to our player / smartphone app.

michaelknoch commented 6 years ago

I ran into this crash when android opens an alert modal f.e when requesting permissions

screenshot_20180505-215048

5-05 21:47:59.177 17731-17731/? A/DEBUG: ABI: 'arm'
05-05 21:47:59.177 17731-17731/? A/DEBUG: pid: 17214, tid: 17214, name: com.flowkey.app  >>> com.flowkey.app <<<
05-05 21:47:59.177 17731-17731/? A/DEBUG: signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 0xac754e48
05-05 21:47:59.197 17731-17731/? A/DEBUG: Abort message: 'fatal error: GPU_Init failed: file /Users/michaelknoch/dev/flow/smartphone-app/RNPlayerComponent/NativePlayerIOS/FlowkeyPlayerSDL/UIKit/Sources/GLRenderer.swift, line 50
                                          '
05-05 21:47:59.197 17731-17731/? A/DEBUG:     r0 00000001  r1 00000001  r2 eb01d2f4  r3 00000080
05-05 21:47:59.198 17731-17731/? A/DEBUG:     r4 00000000  r5 aa054d80  r6 00000032  r7 00000000
05-05 21:47:59.198 17731-17731/? A/DEBUG:     r8 00000002  r9 0000000f  sl ab352165  fp ff863af8
05-05 21:47:59.198 17731-17731/? A/DEBUG:     ip eb013948  sp ff863aa8  lr eaff210f  pc ac754e48  cpsr 600f0010
05-05 21:47:59.202 17731-17731/? A/DEBUG: backtrace:
05-05 21:47:59.203 17731-17731/? A/DEBUG:     #00 pc 00356e48  /data/app/com.flowkey.app-1/lib/arm/libswiftCore.so (_T0s17_assertionFailures5NeverOs12StaticStringV_SSAE4fileSu4lines6UInt32V5flagstFTfq4nxnnn_n+312)
05-05 21:47:59.203 17731-17731/? A/DEBUG:     #01 pc 000705d0  /data/app/com.flowkey.app-1/lib/arm/libUIKit.so
05-05 21:47:59.203 17731-17731/? A/DEBUG:     #02 pc 000a1240  /data/app/com.flowkey.app-1/lib/arm/libUIKit.so
...
cshg commented 6 years ago

Getting the following crash on player close after minimizing it:

05-07 17:12:58.019 26184-26184/? A/SwiftRuntime: fatal error: 'try!' expression unexpectedly raised an error: PlayerLogic.PlayerEvents.(MissingCallbackError in _DEFE8AD1FB64E336D9261846A5570105)(localizedDescription: "Tried to send an event with no callback set"): file /home/johnno/swifty-robot-environment/util/prepare_environment/swift-source/swift/stdlib/public/core/ErrorType.swift, line 181
05-07 17:12:58.499 26184-26184/? A/libc: Fatal signal 4 (SIGILL), code 1, fault addr 0xce71ae48 in tid 26184 (com.flowkey.app)
05-07 17:12:58.559 22118-22118/? A/DEBUG: Build fingerprint: 'samsung/s5neoltexx/s5neolte:6.0.1/MMB29K/G903FXXU1BQC1:user/release-keys'
05-07 17:12:58.559 22118-22118/? A/DEBUG: Revision: '0'
05-07 17:12:58.559 22118-22118/? A/DEBUG: signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 0xce71ae48
05-07 17:12:58.739 22118-22118/? A/DEBUG: Abort message: 'fatal error: 'try!' expression unexpectedly raised an error: PlayerLogic.PlayerEvents.(MissingCallbackError in _DEFE8AD1FB64E336D9261846A5570105)(localizedDescription: "Tried to send an event with no callback set"): file /home/johnno/swifty-robot-environment/util/prepare_environment/swift-source/swift/stdlib/public/core/ErrorType.swift, line 181
                                          '
05-07 17:12:58.739 22118-22118/? A/DEBUG:     r8 00000002  r9 000000c9  sl d20a8154  fp ff9069f0
05-07 17:12:58.739 22118-22118/? A/DEBUG:     ip f4dc2078  sp ff9069a0  lr f7252a73  pc ce71ae48  cpsr 800f0010
05-07 17:12:58.739 22118-22118/? A/DEBUG:     #00 pc 00356e48  /data/app/com.flowkey.app-1/lib/arm/libswiftCore.so (_T0s17_assertionFailures5NeverOs12StaticStringV_SSAE4fileSu4lines6UInt32V5flagstFTfq4nxnnn_n+312)
05-07 17:12:58.739 22118-22118/? A/DEBUG:     #01 pc 001bf91c  /data/app/com.flowkey.app-1/lib/arm/libswiftCore.so (swift_unexpectedError+400)
ephemer commented 6 years ago

@cshg @michaelknoch we have fixed the crashes when loading from the smartphone app, I think we should merge this before we break it again ;) There is a bug with the video disappearing upon reinit on Android 6, but this is already a huge improvement as is so we should merge and release I think

ephemer commented 6 years ago

LGTM