Commit Graph

335 Commits

Author SHA1 Message Date
Jonithan
c3c8ee3ac8 docs: add “重新制作快照” anchor link and "隐私" anchor link (#399) 2020-10-24 16:38:55 +08:00
Yanzhen Yu
7d5d003325 upgrade rrweb-snapshot 2020-10-24 16:36:06 +08:00
Yanzhen Yu
6cef61882e 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.
2020-10-24 15:35:02 +08:00
Yanzhen Yu
0e63852bbc Release 0.9.8 2020-10-23 13:49:37 +08:00
Yanzhen Yu
7c04765752 ignore removed move set 2020-10-23 13:40:13 +08:00
Justin Halsall
07ff4db2a6 Add support for StylesheetRule in document fragment (#293)
* add failing test

* add stylesheet to dom to manipulate the rules

* cleanup
2020-10-17 16:37:32 +08:00
Eoghan Murray
665567119d Suspend mutations during snapshot (#385)
* The `processMutations` function needed to be bound to the `mutationBuffer` object, as otherwise `this` referred to the `MutationObserver` object itself

* Enable external pausing of mutation buffer emissions

 - no automatic pausing based on e.g. pageVisibility yet, assuming such a thing is desirable
   https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
 - user code has to call new API method `freezePage` e.g. when page is hidden or after a timeout
 - automatically unpauses when the next user initiated event occurs
   (am assuming everything that isn't a mutation event counts as 'user initiated'
   either way think this is the correct thing to do until I see a counterexample
   of an event that shouldn't cause the mutations to be unbufferred)

* Avoid a build up of duplicate `adds` by delaying pushing to adds until emission time

* Need to export freezePage in order to use it from rrweb.min.js

* Add a test to check if mutations can be turned off with the `freezePage` method

* I noticed out of order ids (in terms of a DOM walk) in a FullSnapshot.  A DOM mutation was executed against the mirror asynchronously before it could be fully processed. This would lead to a situation in replay where a mutation is executed against a DOM tree that already has the mutation applied. This changeset fixes that by freezing any mutations until the snapshot is completed.

* Remove attribute modifications from a mutation event that were incorrect in that they were repeating the attributes of those nodes present in the 'adds' array of the same mutation

* I've manually verified that this empty text node is actually removed when the dropdown is opened:

document.getElementById('select2-results-1').childNodes
NodeList(2) [li.select2-results-dept-0.select2-result.select2-result-selectable.select2-highlighted, li.select2-results-dept-0.select2-result.select2-result-selectable]

and also that it is not reinstated after the second `await page.click('.select2-container');`

* Rearrange when removal happens in order to satisfy tests. I'm also reverting a recent test change (2600fe7) so that tests pass after this rearrangement; I believe that test change to still be the correct way of doing it, but maybe it is not strictly important that there are extra mutations on attributes of just added nodes

* As mutations are now paused during FullSnapshots, we shouldn't be counting this as a 'user emission'. We automatically emit mutations after unpause anyway ('emit anything queued up now')

* Ensure that we clear arrays before emitting, as the mutation could have the side effect of triggering a FullSnapshot (checkoutEveryNth), which would otherwise re-trigger emission of same mutation (through the new pause/fullsnapshot/mutationemit/unpause process)

* Don't let the programattic pausing during TakeFullSnapshot accidentally unpause a manual call to the API method `freezePage`

* Rename paused -> frozen for consistency and change to use getter/setter access methods
2020-10-04 20:54:10 +08:00
yz-yu
3e18d20418 fix docs link (#386) 2020-10-01 22:19:04 +08:00
yz-yu
c0f8902410 Update zh_CN Docs (#384)
* update zh_CN guide, with latest API and options

* add receipes

* update receipes and guide

* update #329 add links to README
2020-10-01 22:12:54 +08:00
Yanzhen Yu
9488deb6d5 Release 0.9.7 2020-09-23 19:18:21 +08:00
Yanzhen Yu
c5e8d0bee9 fix queue and use a unsafe but performant checker 2020-09-23 19:15:10 +08:00
Yanzhen Yu
8065415de6 Release 0.9.6 2020-09-21 14:01:56 +08:00
jackycoder
f8e88ced7b compatibility fixes (#358)
* fix polyfill NodeList forEach

* contentDocument.contains for IE

* polyfill DOMTokenList forEach
2020-09-20 18:55:29 +08:00
jackycoder
ef84f844ae fix polyfill NodeList forEach (#357) 2020-09-20 15:25:50 +08:00
Yanzhen Yu
64efb8c242 close #356 improve loop checker 2020-09-20 15:06:30 +08:00
Yanzhen Yu
c9391a9c92 Release 0.9.5 2020-09-20 14:16:29 +08:00
Yanzhen Yu
8d8e70400b make sure rrweb do not use browser API in static stage 2020-09-20 14:15:19 +08:00
Justin Halsall
65d0d4e54a child nodes without __sn now remove without error (#307) 2020-09-20 12:58:23 +08:00
Yanzhen Yu
9049f2aef1 close #350 catch error may caused by checkout feature 2020-09-20 12:47:43 +08:00
Yanzhen Yu
9a3e1fe724 fix last played timestamp when it is a mousemove event 2020-09-20 12:37:20 +08:00
Yanzhen Yu
2440701926 impl #309 observe font face set changes 2020-09-17 02:11:34 +08:00
Yanzhen Yu
412f6ca95e Release 0.9.4 2020-09-16 22:57:20 +08:00
Yanzhen Yu
a68684d881 clean up __ln property when remove node 2020-09-16 17:28:07 +08:00
Yanzhen Yu
81c2e547d8 Release 0.9.3 2020-09-12 17:37:47 +08:00
Yanzhen Yu
3abb2981ec close #322 hook select element selectedIndex property 2020-09-12 17:28:29 +08:00
Yanzhen Yu
8519329e90 close #336 add pointer-events: null to mouse tail wrapper 2020-09-12 15:49:41 +08:00
Yanzhen Yu
dbe1c12cc2 update #324, fix typo 2020-09-12 15:49:15 +08:00
Yanzhen Yu
91dc54c7b8 close #342 send SET_SPEED event when setConfig 2020-09-12 15:12:23 +08:00
Yanzhen Yu
52e257627d Release 0.9.2 2020-09-07 22:02:27 +08:00
Yanzhen Yu
41690c755c close #330 implement more accurate finish event 2020-09-07 21:59:57 +08:00
Yanzhen Yu
0688bb6353 close #51 add mouse tail feature 2020-09-07 14:52:57 +08:00
Yanzhen Yu
0256bea4bc hide iframe before first meta event 2020-09-07 12:52:09 +08:00
Yanzhen Yu
c8094c33dc Release 0.9.1 2020-09-07 09:47:17 +08:00
Yanzhen Yu
9b8c7f755f close #161 support "addEvent" in any state 2020-09-07 09:44:03 +08:00
Yanzhen Yu
1bc5aaeb01 close #300 upgrade rrweb-snapshot 2020-09-06 21:34:25 +08:00
Yanzhen Yu
1e4df37093 close #215 catch delete rule errors 2020-09-06 18:47:08 +08:00
Yanzhen Yu
f52b02f4b1 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.
2020-09-06 18:24:27 +08:00
Yanzhen Yu
cdebe18803 close #320 use emitter handler to catch before load state 2020-09-06 18:14:11 +08:00
Yanzhen Yu
9f6f9a8c47 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.
2020-09-06 17:34:29 +08:00
Yanzhen Yu
fa6fd6e2b9 catch unexpected errors during replay media interactions 2020-09-06 17:34:29 +08:00
Justin Halsall
df6d08db97 Only trigger waitForStylesheetLoad if not seeking (#326) 2020-09-06 16:49:44 +08:00
Justin Halsall
6934fab78d Update lastPlayedEvent in live mode (#327)
* Update lastPlayedEvent in live mode

* tricking travis-ci into running again
2020-09-05 17:26:48 +08:00
Justin Halsall
e717cda658 Fix live mode (#310)
* add failing test

* paused -> live now possible
2020-08-27 21:33:12 +08:00
yz-yu
772c0e021a 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
2020-08-22 16:44:02 +08:00
Justin Halsall
a9719e302e Add regression tests and pause(timeOffset) test (#288)
* increase timeout from 2 (default to 10 seconds

* add regression tests for playing multiple times

* add pause at tests
2020-08-20 15:05:25 +08:00
yz-yu
5d83ee39fd close #280. Improve the performance of the DOM mutation observer. (#284)
This issue was originally reported in #280 but may also relate
to #167 and other potential performance issues in the recording.

In #206 I implemented the new mutation observer which will defer
the serialization of DOM, which helps us to have a consistent DOM
order for the replay.

In this implementation, we use an array to represent the `addQueue`.
Whenever we need to consume the queue, we will iterate it to make
sure there is no dead loop, and then shift the first item to see
whether it can be serialized at the new timing.

But this implementation may be very slow when there are a lot of newly
added DOM since it will do an O(n^2) iteration.

For example, if we have three newly added DOM `n1`, `n2`, `n3`,
the iteration looks like this:
```
[n1, n2, n3]
	n1 -> n2 -> n3, consume n3
[n1, n2]
	n1 -> n2, consume n2
[n1]
	n1, consume n1
```
We should have a better performance if te iteration looks like this:
```
[n1, n2, n3]
	n3, consume n3
[n1, n2]
	n2, consume n2
[n1]
	n1, consume n1
```

Simply reverse the mutation payload does not work, because it does
not always as same as the DOM order.

So in this patch, we replace the `addQueue` with a double linked list,
which can:
1. represent the DOM order in its data structure
2. has an O(1) time complexity when looking up the sibling of a list item
3. has an O(1) time complexity when removing a list item
2020-08-16 14:47:25 +08:00
Yanzhen Yu
5e9e1a2522 Release 0.9.0 2020-08-09 13:10:55 +08:00
Yanzhen Yu
be4cccd6e3 close #268 subscribe latest player state before resume 2020-08-09 13:05:55 +08:00
Yanzhen Yu
006b709c00 remove the internal use of resume API 2020-08-09 13:03:12 +08:00
Yanzhen Yu
54baa27b36 remove global body style 2020-08-09 12:50:38 +08:00