From 0c68bd144ef74d3a77cb397dbb47103ac2ae7354 Mon Sep 17 00:00:00 2001 From: Colin Maxfield Date: Wed, 30 Aug 2023 14:08:54 -0400 Subject: [PATCH 1/2] Return early for child same origin frames If we have cross origin record turned on but we are in a child frame that has the same origin as its parent we end up in sort of an inefficient state. We will start the recording, record mutations, but then never actually emit them anywhere since inEmittingFrame and passEmitsToParent are both false. This is a waste of resources and we might as well just never start the recording. --- packages/rrweb/src/record/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/rrweb/src/record/index.ts b/packages/rrweb/src/record/index.ts index 1c2141bfef..b4a19a59d6 100644 --- a/packages/rrweb/src/record/index.ts +++ b/packages/rrweb/src/record/index.ts @@ -114,6 +114,9 @@ function record( if (inEmittingFrame && !emit) { throw new Error('emit function is required'); } + if (!inEmittingFrame && !passEmitsToParent) { + return () => { /* no-op since in this case we don't need to record anything from this frame in particular */ }; + } // move departed options to new options if (mousemoveWait !== undefined && sampling.mousemove === undefined) { sampling.mousemove = mousemoveWait; From 277e92b2b80fcc37453d4c15b45d964715df0511 Mon Sep 17 00:00:00 2001 From: colingm Date: Wed, 30 Aug 2023 18:12:34 +0000 Subject: [PATCH 2/2] Apply formatting changes --- packages/rrweb/src/record/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/rrweb/src/record/index.ts b/packages/rrweb/src/record/index.ts index b4a19a59d6..cdac7f36b1 100644 --- a/packages/rrweb/src/record/index.ts +++ b/packages/rrweb/src/record/index.ts @@ -115,7 +115,9 @@ function record( throw new Error('emit function is required'); } if (!inEmittingFrame && !passEmitsToParent) { - return () => { /* no-op since in this case we don't need to record anything from this frame in particular */ }; + return () => { + /* no-op since in this case we don't need to record anything from this frame in particular */ + }; } // move departed options to new options if (mousemoveWait !== undefined && sampling.mousemove === undefined) {