mirror of
https://github.com/androidx/media.git
synced 2025-05-09 08:30:43 +08:00

Before releasing r2.15.0, we had a regression that crashed PlaybackStatsListener. A change in the AnalyticsCollector made it to send an additional AnalyticsListener.onEvents() callback after calling Player.release() and AnalyticsListener.onEvents() appeared to arrive with event times that were not monotonically increasing. The AnalyticsListener.onEvents() callback that contained AnalyticsListener.EVENT_PLAYER_RELEASED was called with a timestamp that was smaller than event times of previously AnalyticsListener.onEvents() calls. A first fix changed the order of events being forwarded to AnalyticsListener. Upon calling Player.release(), the AnalyticsCollector would call AnalyticsListener.onPlayerReleased() and its associated AnalyticsListener.onEvents() on the same stack call. This fix maintained that event times are monotonically increasing, but made AnalyticsListener.onPlayerReleased() be called earlier. This change: - Further changes AnalyticsCollector to ensure that AnalyticsListener.onPlayerReleased() and its related AnalyticsListener.onEvents() are the last callbacks to be called, and the associated timestamp is bigger than previously reported event times. - Adds an instrumentation test to guard against the regression. PiperOrigin-RevId: 399437724