Repository: dotnet/Silk.NET

Issue #922: Android Crashes when screen rotates
Created: 2022-05-18T14:33:24Z
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

Duplicate issue #1166: imgui on android ERROR
Created: 2022-12-09T06:14:33Z
use AndroidDemo and Silk.NET.OpenGLES.Extensions.ImGui
12-09 06:03:50.639 F/mono-rt ( 6047): [ERROR] FATAL UNHANDLED EXCEPTION: Silk.NET.SDL.SdlException: Couldn't find display mode match
12-09 06:03:50.639 F/mono-rt ( 6047):    at Silk.NET.SDL.Sdl.ThrowError()
12-09 06:03:50.639 F/mono-rt ( 6047):    at Silk.NET.SDL.SdlContext.get_FramebufferSize()
12-09 06:03:50.639 F/mono-rt ( 6047):    at Silk.NET.Windowing.Sdl.SdlView.get_FramebufferSize()
12-09 06:03:50.639 F/mono-rt ( 6047):    at Silk.NET.OpenGLES.Extensions.ImGui.ImGuiController.SetPerFrameImGuiData(Single deltaSeconds)
12-09 06:03:50.639 F/mono-rt ( 6047):    at Silk.NET.OpenGLES.Extensions.ImGui.ImGuiController.Update(Single deltaSeconds)
12-09 06:03:50.639 F/mono-rt ( 6047):    at AndroidDemo.MainActivity.OnRender(Double obj)
12-09 06:03:50.639 F/mono-rt ( 6047):    at Silk.NET.Windowing.Internals.ViewImplementationBase.DoRender()
12-09 06:03:50.639 F/mono-rt ( 6047):    at Silk.NET.Windowing.WindowExtensions.<>c__DisplayClass2_0.b__0()
12-09 06:03:50.639 F/mono-rt ( 6047):    at Silk.NET.Windowing.Internals.ViewImplementationBase.Run(Action onFrame)
12-09 06:03:50.639 F/mono-rt ( 6047):    at Silk.NET.Windowing.WindowExtensions.Run(IView view)
12-09 06:03:50.639 F/mono-rt ( 6047):    at AndroidDemo.MainActivity.OnRun()
12-09 06:03:50.639 F/mono-rt ( 6047):    at Silk.NET.Windowing.Sdl.Android.SilkActivity.Run()
12-09 06:03:50.639 F/mono-rt ( 6047):    at Silk.NET.Windowing.Sdl.Android.SilkActivity.Main()

Closing comment (2023-01-10T16:33:22Z): Duplicate of #922