Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93c47f10 authored by Alex Sakhartchouk's avatar Alex Sakhartchouk
Browse files

Fixing a race condition in RSSurfaceView. Bug 5601083

When destroy is called shortly after creation, RS tries to set a surface on a partially destroyed context.

Change-Id: I7a382a701efde3264e5cd9b9a9b428ade5eb4a9a
parent 99898de9
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
     * This method is part of the SurfaceHolder.Callback interface, and is
     * not normally called or subclassed by clients of RSSurfaceView.
     */
    public void surfaceDestroyed(SurfaceHolder holder) {
    public synchronized void surfaceDestroyed(SurfaceHolder holder) {
        // Surface will be destroyed when we return
        if (mRS != null) {
            mRS.setSurface(null, 0, 0);
@@ -88,7 +88,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
     * This method is part of the SurfaceHolder.Callback interface, and is
     * not normally called or subclassed by clients of RSSurfaceView.
     */
    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
    public synchronized void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
        if (mRS != null) {
            mRS.setSurface(holder, w, h);
        }
@@ -125,7 +125,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
        return rs;
    }

    public void destroyRenderScriptGL() {
    public synchronized void destroyRenderScriptGL() {
        mRS.destroy();
        mRS = null;
    }