@@ -79,16 +79,6 @@ public final class Choreographer {
7979 // be dequeued.
8080 private static final long DEFAULT_FRAME_DELAY = 10 ;
8181
82- // The fake vsync delay in milliseconds.
83- // When the screen is off, we might not receive real vsync pulses from the hardware
84- // which would cause posted Choreographer callbacks to not run. This is bad because
85- // messages in the Looper might be blocked behind a barrier that is scheduled to be
86- // removed by one of those Choreographer callback (see ViewRootImpl.doTraversals).
87- // Until the barrier is removed, those messages will not run. To prevent starvation
88- // of the Looper, we synthesize fake vsync pulses at a reduced rate whenever the
89- // display hardware stops generating them.
90- private static final long FAKE_VSYNC_DELAY = 100 ;
91-
9282 // The number of milliseconds between animation frames.
9383 private static volatile long sFrameDelay = DEFAULT_FRAME_DELAY ;
9484
@@ -123,7 +113,6 @@ protected Choreographer initialValue() {
123113 private static final int MSG_DO_FRAME = 0 ;
124114 private static final int MSG_DO_SCHEDULE_VSYNC = 1 ;
125115 private static final int MSG_DO_SCHEDULE_CALLBACK = 2 ;
126- private static final int MSG_FAKE_VSYNC = 3 ;
127116
128117 // All frame callbacks posted by applications have this token.
129118 private static final Object FRAME_CALLBACK_TOKEN = new Object () {
@@ -598,13 +587,6 @@ void doScheduleCallback(int callbackType) {
598587
599588 private void scheduleVsyncLocked () {
600589 mDisplayEventReceiver .scheduleVsync ();
601-
602- // Post a message to simulate a fake vsync pulse at a reduced rate in case the
603- // display hardware stops generating them. This ensures that Choreographer
604- // callbacks can continue to run even if the screen is off.
605- Message msg = mHandler .obtainMessage (MSG_FAKE_VSYNC );
606- msg .setAsynchronous (true );
607- mHandler .sendMessageDelayed (msg , FAKE_VSYNC_DELAY );
608590 }
609591
610592 private boolean isRunningOnLooperThreadLocked () {
@@ -680,12 +662,6 @@ public void handleMessage(Message msg) {
680662 case MSG_DO_SCHEDULE_CALLBACK :
681663 doScheduleCallback (msg .arg1 );
682664 break ;
683- case MSG_FAKE_VSYNC :
684- if (DEBUG ) {
685- Log .d (TAG , "Handling fake vsync while screen is off." );
686- }
687- doFrame (System .nanoTime (), 0 );
688- break ;
689665 }
690666 }
691667 }
@@ -707,17 +683,6 @@ public void onVsync(long timestampNanos, int frame) {
707683 // the message queue. If there are no messages in the queue with timestamps
708684 // earlier than the frame time, then the vsync event will be processed immediately.
709685 // Otherwise, messages that predate the vsync event will be handled first.
710- if (mHavePendingVsync ) {
711- if (DEBUG ) {
712- Log .d (TAG , "Already have a pending vsync event. There should only be "
713- + "one at a time but they can double up when a fake vsync "
714- + "is handled in place of a real one." );
715- }
716- mHandler .removeCallbacks (this );
717- } else {
718- mHavePendingVsync = true ;
719- }
720-
721686 long now = System .nanoTime ();
722687 if (timestampNanos > now ) {
723688 Log .w (TAG , "Frame time is " + ((timestampNanos - now ) * 0.000001f )
@@ -726,7 +691,12 @@ public void onVsync(long timestampNanos, int frame) {
726691 timestampNanos = now ;
727692 }
728693
729- mHandler .removeMessages (MSG_FAKE_VSYNC );
694+ if (mHavePendingVsync ) {
695+ Log .w (TAG , "Already have a pending vsync event. There should only be "
696+ + "one at a time." );
697+ } else {
698+ mHavePendingVsync = true ;
699+ }
730700
731701 mTimestampNanos = timestampNanos ;
732702 mFrame = frame ;
0 commit comments