square / papa

PAPA: Performance of Android Production Applications
Apache License 2.0
351 stars 15 forks source link

onCurrentFrameRendered should join multiple calls into a single post #35

Closed pyricau closed 2 years ago

pyricau commented 2 years ago

Current impl:

internal fun onCurrentFrameRendered(callback: (Long) -> Unit) {
  mainHandler.postAtFrontOfQueueAsync {
    val frameRenderedUptimeMillis = SystemClock.uptimeMillis()
    callback(frameRenderedUptimeMillis)
  }
}

This should be stateful and aware of any pending calls so that we only register a single call and a single uptime and dispatch to all callbacks