Skip to content

Assess and improve session replay performance using camera view finder #4883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
philprime opened this issue Feb 21, 2025 · 7 comments · Fixed by #5055
Closed

Assess and improve session replay performance using camera view finder #4883

philprime opened this issue Feb 21, 2025 · 7 comments · Fixed by #5055

Comments

@philprime
Copy link
Contributor

philprime commented Feb 21, 2025

Description

  • We need to assess how session replay recording affects video capturing previews, especially using AVFoundation and AVCaptureVideoPreviewLayer
  • Masking preview or disabling recording of preview could be complicated, as it is implemented as a CALayer, rather than UIView
@kahest
Copy link
Member

kahest commented Feb 21, 2025

We have one customer reporting performance issue with camera view finder in their app using SDK 8.41.0. They didn't yet update to 8.43.0, which is the first SDK release where SR is GA. So we should try to reproduce with both/current SDK version.

@kahest kahest moved this from Needs Discussion to Needs Investigation in Mobile SDKs Feb 26, 2025
@philprime philprime self-assigned this Feb 26, 2025
@kahest
Copy link
Member

kahest commented Mar 14, 2025

Also to test whether the performance improvement shipped with the experimental view renderer in 8.47.0 affects this issue

@kahest kahest moved this from Needs Investigation to Needs Validation in Mobile SDKs Mar 26, 2025
@philprime
Copy link
Contributor Author

philprime commented Apr 4, 2025

I created a sample app in #5055 to verify the behaviour with an orange background, a label "Background" and a preview view on top of the label. This is what the screen looked like:

With enableFastViewRendering = false this is the replay:

https://sentry-sdks.sentry.io/explore/replays/28d11e2f3f394a57a46aca12fb3937b6/

With enableFastViewRendering = true this is the replay:

https://sentry-sdks.sentry.io/explore/replays/365ced0a9ff34025a136834e43c48caa/

It seems like we are not able to render the preview layer using either of the render methods.
According to this StackOverflow post it might not even be possible to render the layer due to the inner workings of CPU vs GPU render graphics.

Regarding the performance:

At least on an iPhone 14 Pro I could not see any difference in performance between using the experimental view renderer or not. We might have to perform additional testing on older devices and more complex view hierarchies.

EDIT:
@kahest I believe we should see the AVFoundation camera input as a known limitation. If there is higher demand we could look into custom drawing logic.

@philprime philprime moved this from Needs Validation to Needs Discussion in Mobile SDKs Apr 4, 2025
@kahest
Copy link
Member

kahest commented Apr 4, 2025

At least on an iPhone 14 Pro I could not see any difference in performance between using the experimental view renderer or not. We might have to perform additional testing on older devices and more complex view hierarchies.

To increase confidence I'd like to run some simple tests on an iPhone 8, like we did for #4940.

I believe we should see the AVFoundation camera input as a known limitation. If there is higher demand we could look into custom drawing logic.

That's fair, we should add a note on the docs.

@philprime
Copy link
Contributor Author

philprime commented Apr 8, 2025

I did additional testing with an iPhone 8 using the sample app that will be merged with #5055.

Visually there is no difference noticeable, but Xcode instruments show that the new experimental view renderer has actually more app hangs than without:

Experimental View Renderer:

Image

Default View Renderer:

Image

We might be able to do a more thorough performance analysis with a real use-case, rather than the minimalist sample one.

EDIT: After reviewing the performance tests again it is now visible that there is a clear performance boost reducing view render time from ~157ms to ~40ms

Image
Image

@philprime
Copy link
Contributor Author

Closing this issue because the improvements of the experimental view renderer reduced visible lag using the camera view finder.

@github-project-automation github-project-automation bot moved this from Needs Discussion to Done in Mobile SDKs Apr 8, 2025
@philprime
Copy link
Contributor Author

For future reference, the reason why the initial performance analysis did not show any app hangs when changing the flags was actually a bug, see #5069

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants