From c5e8d0bee9047c5241496e9f901b77d710aae0cf Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Wed, 23 Sep 2020 19:15:10 +0800 Subject: [PATCH] fix queue and use a unsafe but performant checker --- src/replay/index.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/replay/index.ts b/src/replay/index.ts index d545e11c..4a547f9b 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -917,7 +917,7 @@ export class Replayer { next = mirror.getNode(mutation.nextId) as Node; } if (nextNotInDOM(mutation)) { - queue.push(mutation); + return queue.push(mutation); } const target = buildNodeWithSN( @@ -962,12 +962,19 @@ export class Replayer { appendNode(mutation); }); + let startTime = Date.now(); while (queue.length) { - if ( - queue.every( - (m) => !Boolean(mirror.getNode(m.parentId)) || nextNotInDOM(m), - ) - ) { + /** + * Looks like this check is killing the performance + */ + // if ( + // queue.every( + // (m) => !Boolean(mirror.getNode(m.parentId)) || nextNotInDOM(m), + // ) + // ) { + // return queue.forEach((m) => this.warnNodeNotFound(d, m.node.id)); + // } + if (Date.now() - startTime > 5000) { return queue.forEach((m) => this.warnNodeNotFound(d, m.node.id)); } const mutation = queue.shift()!;