Skip to content

Commit

Permalink
Added code to stop gl thread
Browse files Browse the repository at this point in the history
 terminate the thread in callOnDetachFromWindow

Added code to stop gl thread

I added fields to hold the renderer and the GL thread.

In onPause(), I interrupt the GL thread if it's not null.

In onResume(), I start a new GL thread only if the renderer is not null.

I added a setRenderer() method to set the renderer externally.

I introduced a reset() method, annotated with @resetter, which you can use to clean up resources and terminate the GL thread if needed after each test.

 terminate the thread in callOnDetachFromWindow

Update ShadowGLSurfaceView.java
  • Loading branch information
Devashishbasu committed Feb 27, 2024
1 parent c53f25c commit 0f1b308
Showing 1 changed file with 13 additions and 1 deletion.
Expand Up @@ -7,9 +7,21 @@
/** Fake implementation of GLSurfaceView */
@Implements(GLSurfaceView.class)
public class ShadowGLSurfaceView extends ShadowSurfaceView {
private Thread glThread;

@Implementation
protected void onPause() {}

@Implementation
protected void onResume() {}
}

@Override
public void callOnDetachedFromWindow() {
// Terminate the GL thread if it's still running
if (glThread != null && glThread.isAlive()) {
glThread.interrupt();
glThread = null;
}
super.callOnDetachedFromWindow();
}
}

0 comments on commit 0f1b308

Please sign in to comment.