fix(replay): Ensure replays contain canvas rendering when resumed after inactivity #18714
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Replays of apps that use canvas elements that are resumed after a long period of inactivity (for example when navigating away and back to a tab after 5 minutes) were previously broken.
Replays contained all DOM elements, including the canvas, but the canvas would not have any of its rendering captured.
This happens because before resuming from inactivity,
getCanvasManagercreates a newCanvasManagerthat is then passed to a promise resolve function that was already resolved beforehand. That leads to the new canvas manager not actually being used when returning from inactivity and thus having all rendering attempted to be captured from the previous canvas manager instead of the new one.For backwards compatibility, I kept the promise based approach around and added a second storage variable for the canvas manager.
I attempted to create integration tests but was not able to reproduce this issue in an integration test so I opted for just a basic unit test.
I did reproduce this issue in a sample app locally and captured two replays:
The first replay uses our CDN bundles and shows canvas rendering captured at first but missing towards the end of the replay.
The second replay uses bundles built from this PR and shows canvas rendering continues towards the end of the replay.
Closes: #18682