Permalink
Browse files

Fix race condition.

  • Loading branch information...
hrydgard committed Nov 10, 2017
1 parent 378e016 commit c32f505b58831b9ca4fa21cb67037316ed761680
Showing with 10 additions and 5 deletions.
  1. +10 −5 android/src/org/ppsspp/ppsspp/NativeActivity.java
@@ -518,24 +518,29 @@ public void onCreate(Bundle savedInstanceState) {
}
}
Point desiredSize = new Point();
@Override
public void surfaceCreated(SurfaceHolder holder) {
pixelWidth = holder.getSurfaceFrame().width();
pixelHeight = holder.getSurfaceFrame().height();
Log.d(TAG, "Surface created. pixelWidth=" + pixelWidth + ", pixelHeight=" + pixelHeight);
NativeApp.setDisplayParameters(pixelWidth, pixelHeight, (int)densityDpi, refreshRate);
Point sz = new Point();
getDesiredBackbufferSize(sz);
Log.d(TAG, "Setting fixed size " + sz.x + " x " + sz.y);
getDesiredBackbufferSize(desiredSize);
Log.d(TAG, "Setting fixed size " + desiredSize.x + " x " + desiredSize.y);
if (mGLSurfaceView != null) {
mGLSurfaceView.getHolder().setFixedSize(sz.x, sz.y);
mGLSurfaceView.getHolder().setFixedSize(desiredSize.x, desiredSize.y);
} else {
mSurfaceView.getHolder().setFixedSize(sz.x, sz.y);
mSurfaceView.getHolder().setFixedSize(desiredSize.x, desiredSize.y);
}
}
@Override
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.

Show comment
Hide comment
@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]

@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.

Show comment
Hide comment
@hrydgard

hrydgard Nov 11, 2017

Owner

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

@hrydgard

hrydgard Nov 11, 2017

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);
NativeApp.backbufferResize(width, height, format);
mSurface = holder.getSurface();

0 comments on commit c32f505

Please sign in to comment.