Commit Graph

140 Commits

Author SHA1 Message Date
Lucky Feng
10f79eeba4 style: delete a useless constant 2026-04-01 12:00:00 +08:00
Lucky Feng
5ad550c0db fix: elements would lose some states like scroll position because of "virtual parent" optimization (#427)
* fix: elements would lose some state like scroll position because of "virtual parent" optimization

* refactor: the bugfix code

bug: elements would lose some state like scroll position because of "virtual parent" optimization

* fix: an error occured at applyMutation(remove nodes part)

error message:
Uncaught (in promise) DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node
2026-04-01 12:00:00 +08:00
Lucky Feng
d7da4c289c feat: add an option to determine whether to pause CSS animation when playback is paused (#428)
set pauseAnimation to true by default
2026-04-01 12:00:00 +08:00
Lucky Feng
14ed8ad1e6 fix: applyScroll function doesn't work in sync mode(play at a specific time) (#426)
applyScroll function should be called after all of new nodes mounted on dom
2026-04-01 12:00:00 +08:00
Eoghan Murray
8833d3c7ce Ensure animations don't continue playing when we've paused playback (#417) 2026-04-01 12:00:00 +08:00
Eoghan Murray
4726500979 Allow .on to be chained directly after the constructor so that event handling for the first full snapshot can be added straight after constructor. See #216 (#416) 2026-04-01 12:00:00 +08:00
踩坑小王子
13b8a69213 feat: enable to change the config of mouse tail while playing (#410)
fix a potential bug: handleResize function might change the display style of mouseTail
2026-04-01 12:00:00 +08:00
Yanzhen Yu
4137985b01 optimize the append queue algorithm
Loop the append queue has been proved to be very inefficient, and
some times lead to N^2 time complexity.

Especially when some abnormal data could not be appended into the
real DOM, will make a dead loop.

Previously we use a 5000ms time out to handle this, which is not
user-friendly and not explicitly.

In this patch, we transform the queue into a tree data structure,
which reflects the layout of real DOM. With the tree data structure,
we can find whether there are dangling nodes that need to be dropped.
Also, the iteration will be much more efficient.

There is still a 500ms time out to avoid a dead loop, but should not
be called in expected scenarios.
2026-04-01 12:00:00 +08:00
Justin Halsall
455c4d76f4 Add support for StylesheetRule in document fragment (#293)
* add failing test

* add stylesheet to dom to manipulate the rules

* cleanup
2026-04-01 12:00:00 +08:00
Yanzhen Yu
4fc632b40e fix queue and use a unsafe but performant checker 2026-04-01 12:00:00 +08:00
Yanzhen Yu
80172126cf Release 0.9.6 2026-04-01 12:00:00 +08:00
jackycoder
9af39386d4 compatibility fixes (#358)
* fix polyfill NodeList forEach

* contentDocument.contains for IE

* polyfill DOMTokenList forEach
2026-04-01 12:00:00 +08:00
jackycoder
28d599f91b fix polyfill NodeList forEach (#357) 2026-04-01 12:00:00 +08:00
Yanzhen Yu
e6c0f787af close #356 improve loop checker 2026-04-01 12:00:00 +08:00
Yanzhen Yu
0ca0554613 make sure rrweb do not use browser API in static stage 2026-04-01 12:00:00 +08:00
Yanzhen Yu
58504e7d77 close #350 catch error may caused by checkout feature 2026-04-01 12:00:00 +08:00
Yanzhen Yu
8649ae2752 fix last played timestamp when it is a mousemove event 2026-04-01 12:00:00 +08:00
Yanzhen Yu
8b198b338e impl #309 observe font face set changes 2026-04-01 12:00:00 +08:00
Yanzhen Yu
2501993f07 close #336 add pointer-events: null to mouse tail wrapper 2026-04-01 12:00:00 +08:00
Yanzhen Yu
3c7e28b951 update #324, fix typo 2026-04-01 12:00:00 +08:00
Yanzhen Yu
11af001514 close #342 send SET_SPEED event when setConfig 2026-04-01 12:00:00 +08:00
Yanzhen Yu
8f3ea2b76a close #330 implement more accurate finish event 2026-04-01 12:00:00 +08:00
Yanzhen Yu
048aadaec5 close #51 add mouse tail feature 2026-04-01 12:00:00 +08:00
Yanzhen Yu
867ba85049 hide iframe before first meta event 2026-04-01 12:00:00 +08:00
Yanzhen Yu
f83f4e7b13 close #161 support "addEvent" in any state 2026-04-01 12:00:00 +08:00
Yanzhen Yu
51863e9ce8 close #215 catch delete rule errors 2026-04-01 12:00:00 +08:00
Yanzhen Yu
dc782096cb close #319 handle undefined nextId
Looks like some serializer will omit field with null value, so we
do some checks in the replayer to avoid of dead loop.
2026-04-01 12:00:00 +08:00
Yanzhen Yu
0dff4e13fa close #320 use emitter handler to catch before load state 2026-04-01 12:00:00 +08:00
Yanzhen Yu
4bf7bb9bb1 close #303 use a fork version of smooth scroll polyfill
The forked version support customize target window and document,
so we can polyfill it to the iframe.
2026-04-01 12:00:00 +08:00
Yanzhen Yu
04a5dfceef catch unexpected errors during replay media interactions 2026-04-01 12:00:00 +08:00
Justin Halsall
1cec65f565 Only trigger waitForStylesheetLoad if not seeking (#326) 2026-04-01 12:00:00 +08:00
Justin Halsall
d15f4ce8ff Update lastPlayedEvent in live mode (#327)
* Update lastPlayedEvent in live mode

* tricking travis-ci into running again
2026-04-01 12:00:00 +08:00
Justin Halsall
6ebfe69363 Fix live mode (#310)
* add failing test

* paused -> live now possible
2026-04-01 12:00:00 +08:00
yz-yu
6fad7f642c record canvas mutations (#296)
* record canvas mutations

close #60, #261

This patch implements the canvas mutation observer.
It consists of both the record and the replay side changes.

In the record side, we add a `recordCanvas` flag to indicate
whether to record canvas elements and the flag defaults to false.
Different from our other observers, the canvas observer was
disabled by default. Because some applications with heavy canvas
usage may emit a lot of data as canvas changed, especially the
scenarios that use a lot of `drawImage` API.
So the behavior should be audited by users and only record canvas
when the flag was set to true.

In the replay side, we add a `UNSAFE_replayCanvas` flag to indicate
whether to replay canvas mutations.
Similar to the `recordCanvas` flag, `UNSAFE_replayCanvas` defaults
to false. But unlike the record canvas implementation is stable and
safe, the replay canvas implementation is UNSAFE.
It's unsafe because we need to add `allow-scripts` to the replay
sandbox, which may cause some unexpected script execution. Currently,
users should be aware of this implementation detail and enable this
feature carefully.

* update canvas integration test
2026-04-01 12:00:00 +08:00
Yanzhen Yu
3acaeadb93 close #268 subscribe latest player state before resume 2026-04-01 12:00:00 +08:00
Yanzhen Yu
9d686d4302 remove the internal use of resume API 2026-04-01 12:00:00 +08:00
Yanzhen Yu
c17606630e remove global body style 2026-04-01 12:00:00 +08:00
Yanzhen Yu
a31efdc169 close #274 implement the new state management proposal 2026-04-01 12:00:00 +08:00
Eoghan Murray
9362baac3e Reset the lastPlayedEvent as it would otherwise be used to discard events in machine.ts as follows: (#250) 2026-04-01 12:00:00 +08:00
Yanzhen Yu
98f08f333c close #254 hotfix: only use virtual parent in sync mode 2026-04-01 12:00:00 +08:00
Yanzhen Yu
2a133f8214 close #228 safe access content document, which may be destroyed manually 2026-04-01 12:00:00 +08:00
Yanzhen Yu
520ddf3a4f close #244 pass fullsnapshot event to the callback 2026-04-01 12:00:00 +08:00
Eoghan Murray
5b0539419c Restore functioning of #200 - this got broken after #242 (#246)
- What was broken was that it would just play activity from the first page view, but then would stop at the second page view (meta) as actions after that had been discarded
 - This restores the functionality given by the comment 'return the events from last meta to the end.' - we never want to discard events that are after the baseline time
 - I believe 'session' is the incorrect terminology for this function name, as a session in web analytics usually means a series of page views
2026-04-01 12:00:00 +08:00
yz-yu
a8b493799b fix the skip event calculation (#242) 2026-04-01 12:00:00 +08:00
Yanzhen Yu
ae71cf106a tweak the code of getting last session, without splice events array 2026-04-01 12:00:00 +08:00
Yanzhen Yu
19acba745a fast-forward implementation v1
related to #6

Since the currently 'play at any time offset' implementation is pretty simple,
there are many things we can do to optimize its performance.

In this patch, we do the following optimizations:
1. Ignore some of the events during fast forward.
   For example, when we are going to fast forward to 10 minutes later,
   we do not need to perform mouse movement events during this period.
2. Use a fragment element as the 'virtual parent node'.
   So newly added DOM nodes will be appended to this fragment node,
   and finally being appended into the document as a batch operation.
These changes reduce a lot of time which was spent on reflow/repaint previously.
I've seen a 10 times performance improvement within these approaches.

And there are still some things we can do better but not in this patch.
1. We can build a virtual DOM tree to store the mutations of DOM.
   This will minimize the number of DOM operations.
2. Another thing that may help UX is to make the fast forward process async and cancellable.
   This may make the drag and drop interactions in the player's UI looks smooth.
2026-04-01 12:00:00 +08:00
Eoghan Murray
c19aaa7ec0 Only execute events since most recent pageload when playing from an offset (#200)
On recordings with many full pageloads, dom state and mutations were being applied only to be discarded when a new pageload came in, resulting in very slow time to rebuild - and inability to interactively 'scrub' through these recordings
2026-04-01 12:00:00 +08:00
Eoghan Murray
753ee25832 Expose startTime and endTime in the getMetaData() call. I was using player.events[0].timestamp but player.events has gone away (since a78da77 I believe) (#235) 2026-04-01 12:00:00 +08:00
Eoghan Murray
7d7def23d1 Ensure api method .play() can be called by external code without worrying about the internal state of the finite state machine (#236) 2026-04-01 12:00:00 +08:00
Yanzhen Yu
81b3407dd7 export utils as public API 2026-04-01 12:00:00 +08:00