| Summary: | Software render blackscreens on Android | ||
|---|---|---|---|
| Product: | SDL | Reporter: | David Gunter <dr.gunter813> |
| Component: | events | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED DUPLICATE | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | amaranth72, sylvain.becker |
| Version: | 2.0.5 | ||
| Hardware: | ARM | ||
| OS: | Android (All) | ||
I should have mentioned that this issue only shows itself when using software rendering. Does SDL_WINDOWEVENT_EXPOSED get generated in that situation? 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. 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. 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 Can you provide a patch that you've tested for review? Thanks! Maybe related to #3605 SDL_WINDOWEVENT_SIZE_CHANGED invalid the output window. |
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.