@glimt/record 0.0.22 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/record.cjs CHANGED
@@ -367,6 +367,8 @@ const COPY_CANVAS_ON_VOLUME_GREATER_THAN = 25e4;
367
367
  function getReadableCanvasContext(canvas) {
368
368
  if (canvas.width * canvas.height < COPY_CANVAS_ON_VOLUME_GREATER_THAN)
369
369
  return canvas.getContext("2d");
370
+ console.log("cloning canvas for is2DCanvasBlank");
371
+ const start = performance.now();
370
372
  const offscreen = document.createElement("canvas");
371
373
  offscreen.width = canvas.width;
372
374
  offscreen.height = canvas.height;
@@ -374,6 +376,11 @@ function getReadableCanvasContext(canvas) {
374
376
  if (ctx) {
375
377
  ctx.drawImage(canvas, 0, 0);
376
378
  }
379
+ console.log(
380
+ "cloned canvas for is2DCanvasBlank took",
381
+ performance.now() - start,
382
+ "ms"
383
+ );
377
384
  return offscreen.getContext("2d", { willReadFrequently: true });
378
385
  }
379
386
  function is2DCanvasBlank(canvas) {
@@ -1006,17 +1013,25 @@ function serializeElementNode(n2, options) {
1006
1013
  }
1007
1014
  if (tagName === "canvas" && recordCanvas) {
1008
1015
  if (n2.__context === "2d") {
1016
+ const start2dCanvas = performance.now();
1009
1017
  if (!is2DCanvasBlank(n2)) {
1010
1018
  attributes.rr_dataURL = n2.toDataURL(
1011
1019
  dataURLOptions.type,
1012
1020
  dataURLOptions.quality
1013
1021
  );
1014
1022
  }
1023
+ console.log("2d canvas took", performance.now() - start2dCanvas, "ms");
1015
1024
  } else if (!("__context" in n2)) {
1025
+ const startContextCanvas = performance.now();
1016
1026
  const canvasDataURL = n2.toDataURL(
1017
1027
  dataURLOptions.type,
1018
1028
  dataURLOptions.quality
1019
1029
  );
1030
+ console.log(
1031
+ "context canvas first step took",
1032
+ performance.now() - startContextCanvas,
1033
+ "ms"
1034
+ );
1020
1035
  const blankCanvas = doc.createElement("canvas");
1021
1036
  blankCanvas.width = n2.width;
1022
1037
  blankCanvas.height = n2.height;
@@ -1027,6 +1042,11 @@ function serializeElementNode(n2, options) {
1027
1042
  if (canvasDataURL !== blankCanvasDataURL) {
1028
1043
  attributes.rr_dataURL = canvasDataURL;
1029
1044
  }
1045
+ console.log(
1046
+ "context canvas took",
1047
+ performance.now() - startContextCanvas,
1048
+ "ms"
1049
+ );
1030
1050
  }
1031
1051
  }
1032
1052
  if (tagName === "img" && inlineImages) {
@@ -1116,6 +1136,7 @@ function serializeElementNode(n2, options) {
1116
1136
  } catch (e2) {
1117
1137
  }
1118
1138
  const took = performance.now() - start;
1139
+ if (!window.serialization_perf_map) window.serialization_perf_map = {};
1119
1140
  if (!(tagName in window.serialization_perf_map)) {
1120
1141
  window.serialization_perf_map[tagName] = {
1121
1142
  avg: 0,