Skip to content

Commit

Permalink
Fix race condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Nov 10, 2017
1 parent 378e016 commit c32f505
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions android/src/org/ppsspp/ppsspp/NativeActivity.java
Expand Up @@ -518,24 +518,29 @@ public void onCreate(Bundle savedInstanceState) {
} }
} }


Point desiredSize = new Point();

@Override @Override
public void surfaceCreated(SurfaceHolder holder) { public void surfaceCreated(SurfaceHolder holder) {
pixelWidth = holder.getSurfaceFrame().width(); pixelWidth = holder.getSurfaceFrame().width();
pixelHeight = holder.getSurfaceFrame().height(); pixelHeight = holder.getSurfaceFrame().height();
Log.d(TAG, "Surface created. pixelWidth=" + pixelWidth + ", pixelHeight=" + pixelHeight); Log.d(TAG, "Surface created. pixelWidth=" + pixelWidth + ", pixelHeight=" + pixelHeight);
NativeApp.setDisplayParameters(pixelWidth, pixelHeight, (int)densityDpi, refreshRate); NativeApp.setDisplayParameters(pixelWidth, pixelHeight, (int)densityDpi, refreshRate);
Point sz = new Point(); getDesiredBackbufferSize(desiredSize);
getDesiredBackbufferSize(sz); Log.d(TAG, "Setting fixed size " + desiredSize.x + " x " + desiredSize.y);
Log.d(TAG, "Setting fixed size " + sz.x + " x " + sz.y);
if (mGLSurfaceView != null) { if (mGLSurfaceView != null) {
mGLSurfaceView.getHolder().setFixedSize(sz.x, sz.y); mGLSurfaceView.getHolder().setFixedSize(desiredSize.x, desiredSize.y);
} else { } else {
mSurfaceView.getHolder().setFixedSize(sz.x, sz.y); mSurfaceView.getHolder().setFixedSize(desiredSize.x, desiredSize.y);
} }
} }


@Override @Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
if (width != desiredSize.x || height != desiredSize.y) {
Log.w(TAG, "Surface changed but not to desired size. Ignoring.");

This comment has been minimized.

Copy link
@unknownbrackets

unknownbrackets Nov 11, 2017

Collaborator

Can we instead use the holder to detect race conditions? like lastHolder on create, and verify it's the same here?

Or is the holder the same? Naively, I assume that a surface change (like rotate? or dual-screen app?) could happen without a corresponding create.

Would using surfaceRedrawNeeded/surfaceRedrawNeededAsync help at all (to determine that the size change is "final"?

-[Unknown]

This comment has been minimized.

Copy link
@hrydgard

hrydgard Nov 11, 2017

Author Owner

Yeah I'm not happy with this either, gonna see what I can do.

return;
}
Log.w(TAG, "Surface changed. Resolution: " + width + "x" + height + " Format: " + format); Log.w(TAG, "Surface changed. Resolution: " + width + "x" + height + " Format: " + format);
NativeApp.backbufferResize(width, height, format); NativeApp.backbufferResize(width, height, format);
mSurface = holder.getSurface(); mSurface = holder.getSurface();
Expand Down

0 comments on commit c32f505

Please sign in to comment.