square/papa

Windowless onCurrentFrame / onNextFrame?

pyricau opened this issue · 3 comments

Currently these APIs are extension functions on Window because frame metrics are per window.

Need to experiment with multi window (activity + dialog) to see if the metrics actually differ. All windows are rendered in one go. A possible difference might be if each traversal is measured separately? tbd.

If there's no difference, then we maybe could come up with a way to grab any or "the best" window and just run with that, removing the need for a window, which is nice when you're in the middle of your navigation code.

I was wrong. I set up a FrameMetrics for all windows and experimented by creating an activity and a dialog.

First of all, we don't get these every 16ms, but only when frames are actually triggered, ie something's changed. And this is per window, so a window that doesn't change has no callbacks.

When 2 windows do have a frame, they end up having the same start but not the same end. In a way that makes sense, each window is rendered separately.

So the work around is likely not to remove windows, but instead to provide access to the window that issued an event when tracing onclicks etc. That way we can also set a pre draw listener instead of the current choreographer callback, maybe? Would be a way to guarantee that window actually got rendered.

Turns out INTENDED_VSYNC_TIMESTAMP + TOTAL_DURATION gives us the time at which the window content was handed over to the display subsystem, but it's not the time at which that frame was visible to the user. The frame becomes visible on the next vsync. Several windows rendered in the same choreographer callback will have the same INTENDED_VSYNC_TIMESTAMP but different TOTAL_DURATION as they're rendered serially.

The next vsync is easy enough to compute as it's vsync + display rate interval.

Moved back to the post at front hack, which doesn't require a window and isn't impacted by windows rendering serially