designcourse icon indicating copy to clipboard operation
designcourse copied to clipboard

⚡ [RUM-116] On view change, take the full snapshot asynchronously

Open rgaignault opened this issue 1 year ago • 5 comments
trafficstars

Motivation

In the Datadog App, we are starting a new view when the URL changes (via the onChange react-router callback). But at this time, the old page component is still displayed, and we take a full snapshot of the ending view instead of the new view.

Changes

A solution would be to take the fullsnapshot asynchronously. This would let a bit of time to the application UI to be updated. While waiting for the FS to be taken, we could ignore any emitted record, since we would know that a FS is coming to capture the whole state:

startView() is called

ignore any emitted record

[async] wait a bit

if stopSessionReplayRecording() was not called in the meantime

full snapshot is taken

start collecting emitted record again

For the asynchronous delay, we could even use requestIdleCallback to limit our impact on the application perceptible performance.

Testing

  • [x] Local
  • [x] Staging
  • [x] Unit
  • [ ] End to end

I have gone over the contributing documentation.

rgaignault avatar Jul 23 '24 11:07 rgaignault

Codecov Report

Attention: Patch coverage is 96.22642% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.71%. Comparing base (d71c0bd) to head (fd4b76c). Report is 5 commits behind head on main.

Files Patch % Lines
...kages/core/test/emulate/mockRequestIdleCallback.ts 90.47% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2887      +/-   ##
==========================================
+ Coverage   93.68%   93.71%   +0.03%     
==========================================
  Files         266      268       +2     
  Lines        7584     7623      +39     
  Branches     1687     1692       +5     
==========================================
+ Hits         7105     7144      +39     
  Misses        479      479              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Jul 23 '24 12:07 codecov-commenter

/to-staging

rgaignault avatar Jul 23 '24 12:07 rgaignault

:steam_locomotive: Branch Integration: starting soon, median merge time is 12m

Commit 479736c960 will soon be integrated into staging-30.

Use /to-staging -c to cancel this operation!

dd-devflow[bot] avatar Jul 23 '24 12:07 dd-devflow[bot]

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 161.62 KiB 161.80 KiB 181 B +0.11%
Logs 57.95 KiB 57.99 KiB 44 B +0.07%
Rum Slim 110.14 KiB 110.18 KiB 44 B +0.04%
Worker 25.21 KiB 25.21 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base Average Cpu Time (ms) Local Average Cpu Time (ms) 𝚫
addglobalcontext 0.002 0.002 -0.000
addaction 0.041 0.033 -0.007
adderror 0.042 0.031 -0.011
addtiming 0.001 0.001 -0.000
startview 0.974 0.925 -0.049
startstopsessionreplayrecording 1.128 0.812 -0.316
logmessage 0.022 0.019 -0.003
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 20.45 KiB 20.61 KiB 160 B
addaction 73.08 KiB 70.68 KiB -2460 B
adderror 87.32 KiB 86.08 KiB -1267 B
addtiming 19.70 KiB 18.50 KiB -1233 B
startview 350.06 KiB 352.12 KiB 2.06 KiB
startstopsessionreplayrecording 14.03 KiB 15.54 KiB 1.50 KiB
logmessage 68.89 KiB 72.54 KiB 3.64 KiB

🔗 RealWorld

cit-pr-commenter[bot] avatar Jul 23 '24 12:07 cit-pr-commenter[bot]

:steam_locomotive: Branch Integration: This commit was successfully integrated

Commit 479736c960 has been merged into staging-30 in merge commit cc5e316eee.

Check out the triggered pipeline on Gitlab :fox_face:

dd-devflow[bot] avatar Jul 23 '24 12:07 dd-devflow[bot]