When adding event listener, use fuzzy window for last event time.
* We track the last callback time anyways, so there's no risk of double-firing * Without this we might risk missing a dispsync event. E.g., if vsyncs are at T and T+11, and we're considering SF events with +1 offset, then SF will fire at T+1. If we immediately deregister the SF listener, then re-register later at T+13, we miss the event at T+12. But we would probably be ok to fire at T+13 anyways. Note that the old last event time inference did allow for this. See change I742b30a8d28780a44592c4d3077f33d23cf65789... listener.mLastEventTime = systemTime() - mPeriod / 2 + mPhase - mWakeupLatency; ...with +2/+6 offsets and 16.6ms period, then if SF registers at +7ms after vsync, then last event time is inferred to be T-1.3ms, and with reference time T-16.6ms, then the next computed event time ends up being (floor(((T-1.3) - (T-16.6) - 6)/16.6) + 1)* 16.6 + 6 + T-16.6, which ends up being T+6ms, which would immediately cause a wakeup. So this change reintroduces that behavior while keeping the math right. Bug: 128918820 Test: systrace Change-Id: If45be5a579628045ba3d9bfe282bf8831fdb5275
Loading
Please register or sign in to comment