rrweb icon indicating copy to clipboard operation
rrweb copied to clipboard

[Bug]: The emit callback is not called when checkoutEveryNms is used and there's no user activity

Open darind opened this issue 2 years ago • 2 comments

Preflight Checklist

  • [X] I have searched the issue tracker for a bug report that matches the one I want to file, without success.

What package is this bug report for?

rrweb

Expected Behavior

I've configured rrweb to do a full checkout every 60 seconds by using the checkoutEveryNms option:

rrweb.record({
    checkoutEveryNms: 60000,
    emit: (event, isCheckout) => {
        console.log(isCheckout);
    }
});

I expect that the emit callback is called every 60 seconds with the isCheckout parameter set to true and the corresponding event represents a full DOM snapshot.

Actual Behavior

This works fine if there is some activity on the page (e.g. click, input, mouse move, ...etc). But if there's no activity, the emit callback is never called.

Since I need to replay only a sliding portion of the video (e.g. the last 3 minutes from a 10 minutes video), I scheduled invisible DOM changes every 30 seconds (like adding a hidden span) in order to get the correct number of events in the eventsMatrix.

Also I tried using the addCustomEvent and in this case the emit callback is raised but the isCheckout parameter is always false (see https://github.com/rrweb-io/rrweb/issues/763)

Testcase Gist URL

No response

Additional Information

No response

darind avatar Aug 17 '22 10:08 darind

Good catch, currently the checkout feature is lazy, which means only calculates when new events come. So the semantics of checkoutEveryNms does not work like setInterval.

Using a custom event is a good try and I will check why it does not work. (Looks like I missed #763 before...)

Yuyz0112 avatar Aug 17 '22 14:08 Yuyz0112

I've sent a draft PR and comments are welcomed!

Yuyz0112 avatar Aug 17 '22 15:08 Yuyz0112

I have same question,how can I resove it

sce9966 avatar Jul 06 '23 08:07 sce9966