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.
This commit is contained in:
Yanzhen Yu
2020-10-24 15:35:02 +08:00
parent 0e63852bbc
commit 6cef61882e
3 changed files with 114 additions and 30 deletions

View File

@@ -157,7 +157,7 @@ describe('record', function (this: ISuite) {
expect(this.events[35].type).to.equal(EventType.FullSnapshot);
});
it.only('is safe to checkout during async callbacks', async () => {
it('is safe to checkout during async callbacks', async () => {
await this.page.evaluate(() => {
const { record } = ((window as unknown) as IWindow).rrweb;
record({