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
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
|||||||
eventWithTime,
|
eventWithTime,
|
||||||
actionWithDelay,
|
actionWithDelay,
|
||||||
ReplayerEvents,
|
ReplayerEvents,
|
||||||
|
EventType,
|
||||||
Emitter,
|
Emitter,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { Timer, getDelay } from './timer';
|
import { Timer, getDelay } from './timer';
|
||||||
@@ -169,8 +170,22 @@ export function createPlayerService(
|
|||||||
play(ctx) {
|
play(ctx) {
|
||||||
const { timer, events, baselineTime, lastPlayedEvent } = ctx;
|
const { timer, events, baselineTime, lastPlayedEvent } = ctx;
|
||||||
timer.clear();
|
timer.clear();
|
||||||
const actions = new Array<actionWithDelay>();
|
const needed_events = new Array<eventWithTime>();
|
||||||
for (const event of events) {
|
for (const event of events) {
|
||||||
|
if (event.timestamp < baselineTime &&
|
||||||
|
event.type === EventType.FullSnapshot &&
|
||||||
|
needed_events.length > 0 &&
|
||||||
|
needed_events[needed_events.length -1].type === EventType.Meta
|
||||||
|
) {
|
||||||
|
// delete everything before Meta
|
||||||
|
// so that we only rebuild from the latest full snapshot
|
||||||
|
needed_events.splice(0, needed_events.length -1);
|
||||||
|
}
|
||||||
|
needed_events.push(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
const actions = new Array<actionWithDelay>();
|
||||||
|
for (const event of needed_events) {
|
||||||
if (
|
if (
|
||||||
lastPlayedEvent &&
|
lastPlayedEvent &&
|
||||||
(event.timestamp <= lastPlayedEvent.timestamp ||
|
(event.timestamp <= lastPlayedEvent.timestamp ||
|
||||||
|
|||||||
Reference in New Issue
Block a user