We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3628 - Software render blackscreens on Android
Summary: Software render blackscreens on Android
Status: RESOLVED DUPLICATE of bug 4669
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.5
Hardware: ARM Android (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-12 23:13 UTC by David Gunter
Modified: 2019-06-17 20:34 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Gunter 2017-04-12 23:13:38 UTC
At line 133 in SDL_windowevents.c:

if (data1 == window->w && data2 == window->h) {
            return 0;
        }

This check prevents the sdl window on Android from updating properly, since a resize event is sent when resuming from a suspend(the window surface changes in this case, but is usually the same dimension).

I'm currently just skiiping this check to work around it, but that doesn;t seem like an optimal solution to the problem.
Comment 1 David Gunter 2017-04-12 23:15:07 UTC
I should have mentioned that this issue only shows itself when using software rendering.
Comment 2 Alex Szpakowski 2017-04-14 07:52:28 UTC
Does SDL_WINDOWEVENT_EXPOSED get generated in that situation?
Comment 3 David Gunter 2017-04-21 01:28:31 UTC
There's actually a lot more to this issue than just the resize event getting blocked. When I get a chance, I'll put together a patch for my solution. Although, I'm not certain the workaround I'm using to get software rendering working properly on Android is really the best way to go about it.
Comment 4 David Gunter 2017-05-13 21:03:17 UTC
Renamed this now that I have a better understanding of the issue.

When using software rendering, calls to SurfaceChanged in SDLActivity.java are not thread safe, and can cause unrecoverable context loss due to conflicts between the window framebuffer and the context backup/restore functions.

I solved this by pausing the SDL thread, adding a semaphore to halt the Java thread at the beginning of SurfaceChanged(), resuming the Java thread after the SDL thread has finished pausing, and resuming the SDL thread after the surface change has completed.
Comment 5 David Gunter 2017-05-14 04:52:43 UTC
Well, now I feel rather foolish. I was misled by errors involving EGL_BAD_ACCESS. It appears they don't matter(my application is still spitting them out every time the screen is rotated, and carries on just fine.)

It turns out, all that's needed to get the software renderer to behave itself is:

Android_Window->surface_valid = SDL_FALSE;

In both egl_context_restore() and onNativeSurfaceChanged().

And adding mSurface.setVisibility(View.GONE); and mSurface.setVisibility(View.VISIBLE); to onPause() and onResume() in SDLActivity.java
Comment 6 Sam Lantinga 2017-08-11 18:42:18 UTC
Can you provide a patch that you've tested for review?

Thanks!
Comment 7 Sylvain 2017-08-12 11:53:01 UTC
Maybe related to #3605

SDL_WINDOWEVENT_SIZE_CHANGED invalid the output window.
Comment 8 Sylvain 2019-06-17 20:34:40 UTC
This really sounds a duplicate of 4669

*** This bug has been marked as a duplicate of bug 4669 ***