Skip to content

Commit

Permalink
Fix TextureMode crash (#3144)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-cojocaru authored Jan 21, 2025
1 parent 5b45d70 commit 6c88f72
Showing 1 changed file with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public void run() {

while (true) {
Runnable event = null;
boolean initialize = false;
boolean createSurface = false;
boolean destroySurface = false;
boolean sizeChanged = false;
int w = -1;
int h = -1;

Expand All @@ -41,20 +43,28 @@ public void run() {
break;
}

if (destroySurface) {
destroySurface = false;
mapRenderer.onSurfaceDestroyed();
if (this.destroySurface) {
surface = null;
destroySurface = true;
this.destroySurface = false;
break;
}

if (surfaceTexture != null && !paused && requestRender && surface == null) {
if (surfaceTexture != null && !paused && requestRender
&& (surface == null || this.sizeChanged)) {

w = width;
h = height;
surface = new Surface(surfaceTexture);

initialize = true;
if (surface == null) {
surface = new Surface(surfaceTexture);
createSurface = true;
}

if (this.sizeChanged) {
sizeChanged = true;
this.sizeChanged = false;
}

// Reset the request render flag now, so we can catch new requests
// while rendering
Expand All @@ -81,14 +91,19 @@ public void run() {
continue;
}

if (initialize) {
if (createSurface) {
mapRenderer.onSurfaceCreated(surface);
mapRenderer.onSurfaceChanged( w, h);

initialize = false;
mapRenderer.onSurfaceChanged(w, h);
createSurface = false;
continue;
}

if (destroySurface) {
mapRenderer.onSurfaceDestroyed();
destroySurface = false;
break;
}

// If the surface size has changed inform the map renderer.
if (sizeChanged) {
mapRenderer.onSurfaceChanged(w, h);
Expand Down

0 comments on commit 6c88f72

Please sign in to comment.