Skip to content

Commit

Permalink
Potential fix for #68
Browse files Browse the repository at this point in the history
  • Loading branch information
patzly committed Sep 18, 2022
1 parent a4220e4 commit 187601e
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ private class UserAwareEngine extends Engine implements UserPresenceListener, Re
private boolean isSurfaceAvailable;
private boolean isVisible;
private boolean isPreview;
private boolean usedGlitchWorkaround;
private float fps;
private int screenRotation;
private long lastFrameDraw;
Expand Down Expand Up @@ -361,6 +362,7 @@ public void onAccuracyChanged(Sensor sensor, int accuracy) {}
display = windowManager.getDefaultDisplay();
fps = display.getRefreshRate();
screenRotation = display.getRotation();
usedGlitchWorkaround = false;

timerUtil = new TimerUtil(() -> {
// refresh random
Expand Down Expand Up @@ -511,6 +513,17 @@ public void onOffsetsChanged(
return;
}
}

// workaround for glitch during unlocking, xOffset is 0 in one frame
if (offsetX > 0.08 && xOffset == 0) {
if (!usedGlitchWorkaround) { // produce frame jump only once
usedGlitchWorkaround = true;
return;
} else {
usedGlitchWorkaround = false;
}
}

lastRawOffsetX = xOffset;

if (isRtl && !isPreview) {
Expand Down Expand Up @@ -539,6 +552,7 @@ public void onZoomChanged(float zoom) {
public void onPresenceChange(String presence) {
switch (presence) {
case USER_PRESENCE.OFF:
usedGlitchWorkaround = false; // new unlock anim next time
if (randomMode.equals(RANDOM.SCREEN_OFF)
|| (randomMode.equals(RANDOM.DAILY) && isNewRandomPending)
|| (randomMode.equals(RANDOM.INTERVAL) && isNewRandomPending)) {
Expand Down Expand Up @@ -961,7 +975,6 @@ private void updateOffset(boolean force, String source) {
xOffset + finalTiltX * tiltFactor,
finalTiltY * tiltFactor
);
//Log.i(TAG, "updateOffset: hello x=" + (int)(xOffset + finalTiltX * tiltFactor) + ", y=" + (int)(finalTiltY * tiltFactor));
drawFrame(force, source);
}

Expand Down

0 comments on commit 187601e

Please sign in to comment.