Skip to content

Conversation

philprime
Copy link
Member

@philprime philprime commented Oct 6, 2025

📜 Description

Fix incorrect implementation of fast view rendering in SentryViewRendererV2 by switching from CALayer.draw(in:) to CALayer.render(in:).

Why this matters:

  • CALayer.draw(in:) only draws the layer's own contents and does not include sublayers
  • CALayer.render(in:) rasterizes the entire visual tree including all sublayers, which is required for accurate session replay snapshots

💡 Motivation and Context

This fixes a regression introduced in PR #4940 where the wrong CALayer method was accidentally merged. The original PR tested CALayer.render(in:) and showed significant performance improvements (~160ms to ~30-36ms on iPhone 8), but CALayer.draw(in:) was merged instead.

For session replay, we need the complete visual representation including all sublayers, making render(in:) the correct choice, even if the fast view renderer is incomplete.

Fixes the incorrect implementation from PR #4940.

💚 How did you test it?

Manual testing with session replay enabled in iOS-Swift sample app.

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

@philprime philprime changed the title fix(session-replay): Update rendering method for fast view renderering fix(session-replay): Update rendering method for fast view rendering Oct 6, 2025
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

Copy link

codecov bot commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.301%. Comparing base (7aaa0b6) to head (1beaa83).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../Core/Tools/ViewCapture/SentryViewRendererV2.swift 0.000% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #6360       +/-   ##
=============================================
+ Coverage   86.818%   87.301%   +0.482%     
=============================================
  Files          438       438               
  Lines        37311     37311               
  Branches     17428     17434        +6     
=============================================
+ Hits         32393     32573      +180     
+ Misses        4874      4693      -181     
- Partials        44        45        +1     
Files with missing lines Coverage Δ
.../Core/Tools/ViewCapture/SentryViewRendererV2.swift 92.857% <0.000%> (ø)

... and 9 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7aaa0b6...1beaa83. Read the comment docs.

Copy link
Contributor

github-actions bot commented Oct 6, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1217.45 ms 1255.51 ms 38.06 ms
Size 23.75 KiB 989.94 KiB 966.19 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
2ec2700 1238.28 ms 1258.82 ms 20.53 ms
d0f70ce 1226.54 ms 1247.04 ms 20.50 ms
5bf2b17 1213.53 ms 1238.54 ms 25.01 ms
efab7d3 1219.98 ms 1252.12 ms 32.14 ms
e3ebff3 1223.47 ms 1249.27 ms 25.80 ms
7b3399c 1193.35 ms 1227.38 ms 34.03 ms
3133d0e 1237.86 ms 1262.87 ms 25.01 ms
22b6996 1234.00 ms 1263.24 ms 29.24 ms
43597ba 1214.88 ms 1243.52 ms 28.65 ms
fc6557e 1226.40 ms 1249.88 ms 23.48 ms

App size

Revision Plain With Sentry Diff
2ec2700 23.75 KiB 980.80 KiB 957.05 KiB
d0f70ce 23.75 KiB 913.09 KiB 889.34 KiB
5bf2b17 23.75 KiB 913.27 KiB 889.52 KiB
efab7d3 23.75 KiB 912.78 KiB 889.03 KiB
e3ebff3 23.75 KiB 878.48 KiB 854.73 KiB
7b3399c 23.75 KiB 946.68 KiB 922.94 KiB
3133d0e 23.74 KiB 976.79 KiB 953.04 KiB
22b6996 23.75 KiB 908.02 KiB 884.27 KiB
43597ba 23.75 KiB 880.32 KiB 856.58 KiB
fc6557e 23.75 KiB 866.68 KiB 842.93 KiB

@philprime philprime enabled auto-merge (squash) October 7, 2025 07:04
@philprime philprime merged commit 80538ca into main Oct 7, 2025
247 of 262 checks passed
@philprime philprime deleted the philprime/fix-fast-view-renderer branch October 7, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants