Skip to content
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

fix(replay): Fixes Firefox playback issues #81199

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

billyvg
Copy link
Member

@billyvg billyvg commented Nov 22, 2024

... due to shared object references in replayStepper. This happens on Replay details page where we have the replayer as well as a tab that uses replayStepper (e.g. Breadcrumbs). Both Replayer instances were access the same rrweb event object references and because replayStepper plays through the entire replay as fast as possible, it ends up mutating the event objects that the player instance later reads. This ends up causing issues in the playback (like screens not updating so the replay appears frozen and broken). I don't know exactly what mutations are happening that cause the playback issues, nor do I know why it only affects Firefox and not Chrome.

We now deep clone the events in createHiddenPlayer to avoid the above situation.

We first realized this was an issue with replayStepper due to #80681 and its fix. The events in our hidden replayer were affecting our main playback which indicates that there was some shared state happening. h/t @ryan953 for the suggestion re: object mutations!

Closes getsentry/sentry-javascript#14381
Closes getsentry/sentry-javascript#12978

... due to shared object references in `replayStepper`. This happens on Replay details page where we have the replayer as well as a tab that uses `replayStepper` (e.g. Breadcrumbs). Both `Replayer` instances were access the same rrweb event object references and because `replayStepper` plays through the entire replay as fast as possible, it ends up mutating the event objects that the player instance later reads. This ends up causing issues in the playback (like screens not updating so the replay appears frozen and broken).

We now deep clone the events in `createHiddenPlayer` to avoid the above situation.
// Replay details player and a hidden player via `replayStepper`) can cause
// playback issues as the object references are the same, even though the
// arrays are not.
structuredClone(rrwebEvents),
Copy link
Member Author

Choose a reason for hiding this comment

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

https://caniuse.com/?search=structuredClone (supported by 94% of browsers)

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 22, 2024
@billyvg billyvg marked this pull request as ready for review November 22, 2024 19:19
@billyvg billyvg requested a review from a team as a code owner November 22, 2024 19:19
Copy link

codecov bot commented Nov 22, 2024

Bundle Report

Changes will increase total bundle size by 14.48kB (0.05%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
app-webpack-bundle-array-push 31.98MB 14.48kB (0.05%) ⬆️

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
static/app/utils/replays/createHiddenPlayer.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #81199   +/-   ##
=======================================
  Coverage   80.32%   80.32%           
=======================================
  Files        7215     7215           
  Lines      319443   319465   +22     
  Branches    20773    20775    +2     
=======================================
+ Hits       256583   256612   +29     
+ Misses      62466    62459    -7     
  Partials      394      394           

@billyvg billyvg merged commit 9d8bebb into master Nov 22, 2024
48 of 49 checks passed
@billyvg billyvg deleted the fix-replay-fix-firefox-playback-issues branch November 22, 2024 20:02
harshithadurai pushed a commit that referenced this pull request Nov 25, 2024
... due to shared object references in `replayStepper`. This happens on
Replay details page where we have the replayer as well as a tab that
uses `replayStepper` (e.g. Breadcrumbs). Both `Replayer` instances were
access the same rrweb event object references and because
`replayStepper` plays through the entire replay as fast as possible, it
ends up mutating the event objects that the player instance later reads.
This ends up causing issues in the playback (like screens not updating
so the replay appears frozen and broken). I don't know exactly what
mutations are happening that cause the playback issues, nor do I know
why it only affects Firefox and not Chrome.

We now deep clone the events in `createHiddenPlayer` to avoid the above
situation.

We first realized this was an issue with `replayStepper` due to
#80681 and [its
fix](#80697). The events in our
hidden replayer were affecting our main playback which indicates that
there was some shared state happening. h/t @ryan953 for the suggestion
re: object mutations!

Closes getsentry/sentry-javascript#14381
Closes getsentry/sentry-javascript#12978
evanh pushed a commit that referenced this pull request Nov 25, 2024
... due to shared object references in `replayStepper`. This happens on
Replay details page where we have the replayer as well as a tab that
uses `replayStepper` (e.g. Breadcrumbs). Both `Replayer` instances were
access the same rrweb event object references and because
`replayStepper` plays through the entire replay as fast as possible, it
ends up mutating the event objects that the player instance later reads.
This ends up causing issues in the playback (like screens not updating
so the replay appears frozen and broken). I don't know exactly what
mutations are happening that cause the playback issues, nor do I know
why it only affects Firefox and not Chrome.

We now deep clone the events in `createHiddenPlayer` to avoid the above
situation.

We first realized this was an issue with `replayStepper` due to
#80681 and [its
fix](#80697). The events in our
hidden replayer were affecting our main playback which indicates that
there was some shared state happening. h/t @ryan953 for the suggestion
re: object mutations!

Closes getsentry/sentry-javascript#14381
Closes getsentry/sentry-javascript#12978
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replays in Sentry no showing correct pages. Session replay not rendering correctly on firefox
2 participants