Skip to content

App Hang/Session Replay should use runloop observersΒ #5263

@noahsmartin

Description

@noahsmartin

Problem Statement

The app hang implementation (and session replay) is using CADisplayLink which causes it to use the main thread every frame. Instead of forcing the runloop to execute as fast as possible it should use a runloop observer that only measures the duration of runloop iterations that would otherwise be executing. This is a more passive way of detecting hangs that has much less overhead.

For session replay it would also allow capturing only the frames that actually change. However, it won't run during animations that are control by the Core Animation render server rather than the apps main run loop. This is probably not a problem, just a difference from CADisiplayLink behavior.

This screenshot shows how the main thread is constantly being used even when the user is not interacting with the app, since the hang detection feature is spinning the runloop
Image

Solution Brainstorm

No response

Are you willing to submit a PR?

Yes!

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions