Skip to content

[Bug]: Recorder initializes very late in page load lifecycle #1090

@lazyvab

Description

@lazyvab

Preflight Checklist

  • 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

Version

v1.1.3

Expected Behavior

I am using RRWeb in a Chrome extension to record activity on a website.
I inject RRWeb library in the webpage on document_start and call the record() function as soon as possible, so recording may start earliest in page load lifecycle and should not wait for complete page to load (like images). To start capturing DOM state, it should only wait for DOMContentLoaded event.

Along with DOM state, it should also start capturing console logs as early as possible.

Actual Behavior

The RRWeb recorder seems to initialize only when window load event is fired which means the webpage has loaded completely including resources like images.

I was looking at the source code, according to which if the webpage is still in loading state, that is, document.readyState="loading", it would wait for window load event which is fired after all resources have been loaded.
In my case, the whole website loads except for few images which are delayed for almost a minute and recording could not start until then.
IMHO, it should rather wait for DOMContentLoaded event and start observing DOM as soon as it is ready.

Steps to Reproduce

Covered above.

Testcase Gist URL

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghas PRalready has pull request for it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions