Skip to content

Commit 93c47f1

Browse files
author
Alex Sakhartchouk
committed
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
1 parent 99898de commit 93c47f1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

graphics/java/android/renderscript/RSSurfaceView.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import android.view.SurfaceView;
3131

3232
/**
33-
* The Surface View for a graphics renderscript (RenderScriptGL) to draw on.
33+
* The Surface View for a graphics renderscript (RenderScriptGL) to draw on.
3434
*/
3535
public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback {
3636
private SurfaceHolder mSurfaceHolder;
@@ -77,7 +77,7 @@ public void surfaceCreated(SurfaceHolder holder) {
7777
* This method is part of the SurfaceHolder.Callback interface, and is
7878
* not normally called or subclassed by clients of RSSurfaceView.
7979
*/
80-
public void surfaceDestroyed(SurfaceHolder holder) {
80+
public synchronized void surfaceDestroyed(SurfaceHolder holder) {
8181
// Surface will be destroyed when we return
8282
if (mRS != null) {
8383
mRS.setSurface(null, 0, 0);
@@ -88,7 +88,7 @@ public void surfaceDestroyed(SurfaceHolder holder) {
8888
* This method is part of the SurfaceHolder.Callback interface, and is
8989
* not normally called or subclassed by clients of RSSurfaceView.
9090
*/
91-
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
91+
public synchronized void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
9292
if (mRS != null) {
9393
mRS.setSurface(holder, w, h);
9494
}
@@ -125,7 +125,7 @@ public RenderScriptGL createRenderScriptGL(RenderScriptGL.SurfaceConfig sc) {
125125
return rs;
126126
}
127127

128-
public void destroyRenderScriptGL() {
128+
public synchronized void destroyRenderScriptGL() {
129129
mRS.destroy();
130130
mRS = null;
131131
}

0 commit comments

Comments
 (0)