Android Crashes when screen rotates
Summary
Basically the app just crashes when the screen rotate, even without any rendering code. The problem is on SDL, when your app rotates it called SDL_Quit or something (not sure) but basically the screen surface is destroyed
Steps to reproduce
- Platform: Android
- Framework Version: .NET 6 android
- API: SDL
- I created a new android project with
dotnet new - Then I copied some code from the example repo
- It works, but when I rotate it, it crashes
Comments
Errors that were found:
[DecorView[]] getWindowModeFromSystem windowmode is 1
[libEGL] validate_display:87 error 3008 (EGL_BAD_DISPLAY)
[SDL] surfaceDestroyed()
[SDL] nativePause()
[SDL] surfaceCreated()
[SDL] surfaceChanged()
[SDL] pixel format RGBA_8888
[SDL] Window size: 2177x855
[SDL] Device size: 1080x2400
[SDL] nativeResume()
[Looper] PerfMonitor longMsg : seq=58 plan=15:32:27.306 late=8ms wall=1928ms running=28ms runnable=80ms binder=90ms h=org.libsdl.app.SDLActivity$SDLCommandHandler w=0 procState=18
[SDL] surfaceDestroyed()
[SDL] nativePause()
[SDL] onStop()
[SDL] onDestroy()
[Looper] PerfMonitor doFrame : time=64ms vsyncFrame=1218431 latency=675ms procState=18 historyMsgCount=7 (msgIndex=2 wall=645ms seq=233 running=22ms runnable=1ms binder=21ms late=102ms h=org.libsdl.app.SDLActivity$SDLCommandHandler w=0)
[OpenGLRenderer] Davey! duration=749ms; Flags=1, IntendedVsync=25496197045159, Vsync=25496872045132, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=25496873638449, AnimationStart=25496873642980, PerformTraversalsStart=25496875238293, DrawStart=25496928107564, SyncQueued=25496933524751, SyncStart=25496934146262, IssueDrawCommandsStart=25496935063345, SwapBuffers=25496943527772, FrameCompleted=25496947080637, DequeueBufferDuration=1200885, QueueBufferDuration=2394167, GpuCompleted=9223372036854775807,
[SDL] surfaceDestroyed()
[SDL] nativePause()
**Silk.NET.SDL.SdlException:** 'Couldn't find display mode match'
Note: I double checked and decompiled the resulting apk, and it does have android:configChanges set to the correct values
I also have that problem.
I assume that the problem is caused because the SDL window is created without SDL_WINDOW_RESIZABLE flag (see: https://lazyfoo.net/tutorials/SDL/53_extensions_and_changing_orientation/index2.php).
I have quickly checked the source code and saw that when creating a SdlView the WindowFlags.WindowResizable is not set because the _platform.IsViewOnly is true (see SdlView.CoreInitialize method).
It would be also possible to provide WindowFlags.WindowResizable in the additionalFlags parameter, but I do not see how a user would be able to set that and call SdlView.CoreInitialize method.
I cannot compile Silk.Net source so I cannot test that. Maybe this will help you solve this problem sooner.
Closed by #1372