mellinoe / veldrid-samples

Sample projects for Veldrid
https://mellinoe.github.io/veldrid-docs/
121 stars 48 forks source link

Android- black screen after sleeping and waking up the phone #18

Open tzachshabtay opened 5 years ago

tzachshabtay commented 5 years ago

Trying the TexturedCube sample on a Galaxy S8 with Android 9.

The sample renders fine at first, but if I put my phone to sleep and then re-awake it, it only shows a black screen. I tried both with Vulkan and OpenGLES. At first I saw Null exceptions on https://github.com/mellinoe/veldrid-samples/blob/21b81c72aa67d3726ce44b1e87089b460a381fab/src/SampleBase.Android/VeldridSurfaceView.cs#L150 and https://github.com/mellinoe/veldrid-samples/blob/21b81c72aa67d3726ce44b1e87089b460a381fab/src/SampleBase.Android/VeldridSurfaceView.cs#L155.

I changed that MainSwapchain?.Dispose(); and GraphicsDevice?.Dispose(); to see if that solves it. It doesn't. For vulkan, I don't see any more errors but it only renders a black screen. For opengles, I still get null exceptions from the rendering loop itself, sometimes GraphicsDevice is null and sometimes MainSwapchain is null.

Looking at the SurfaceCreated method, it seems that you recreate the device and swapchain, but shouldn't you also recreate textures/pipelines/etc?