@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 +21 -0
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +21 -0
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +21 -0
- package/dist/record.umd.cjs.map +2 -2
- package/dist/record.umd.min.cjs +6 -6
- package/dist/record.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/record.umd.cjs
CHANGED
|
@@ -399,6 +399,8 @@ const COPY_CANVAS_ON_VOLUME_GREATER_THAN = 25e4;
|
|
|
399
399
|
function getReadableCanvasContext(canvas) {
|
|
400
400
|
if (canvas.width * canvas.height < COPY_CANVAS_ON_VOLUME_GREATER_THAN)
|
|
401
401
|
return canvas.getContext("2d");
|
|
402
|
+
console.log("cloning canvas for is2DCanvasBlank");
|
|
403
|
+
const start = performance.now();
|
|
402
404
|
const offscreen = document.createElement("canvas");
|
|
403
405
|
offscreen.width = canvas.width;
|
|
404
406
|
offscreen.height = canvas.height;
|
|
@@ -406,6 +408,11 @@ function getReadableCanvasContext(canvas) {
|
|
|
406
408
|
if (ctx) {
|
|
407
409
|
ctx.drawImage(canvas, 0, 0);
|
|
408
410
|
}
|
|
411
|
+
console.log(
|
|
412
|
+
"cloned canvas for is2DCanvasBlank took",
|
|
413
|
+
performance.now() - start,
|
|
414
|
+
"ms"
|
|
415
|
+
);
|
|
409
416
|
return offscreen.getContext("2d", { willReadFrequently: true });
|
|
410
417
|
}
|
|
411
418
|
function is2DCanvasBlank(canvas) {
|
|
@@ -1039,17 +1046,25 @@ function serializeElementNode(n2, options) {
|
|
|
1039
1046
|
}
|
|
1040
1047
|
if (tagName === "canvas" && recordCanvas) {
|
|
1041
1048
|
if (n2.__context === "2d") {
|
|
1049
|
+
const start2dCanvas = performance.now();
|
|
1042
1050
|
if (!is2DCanvasBlank(n2)) {
|
|
1043
1051
|
attributes.rr_dataURL = n2.toDataURL(
|
|
1044
1052
|
dataURLOptions.type,
|
|
1045
1053
|
dataURLOptions.quality
|
|
1046
1054
|
);
|
|
1047
1055
|
}
|
|
1056
|
+
console.log("2d canvas took", performance.now() - start2dCanvas, "ms");
|
|
1048
1057
|
} else if (!("__context" in n2)) {
|
|
1058
|
+
const startContextCanvas = performance.now();
|
|
1049
1059
|
const canvasDataURL = n2.toDataURL(
|
|
1050
1060
|
dataURLOptions.type,
|
|
1051
1061
|
dataURLOptions.quality
|
|
1052
1062
|
);
|
|
1063
|
+
console.log(
|
|
1064
|
+
"context canvas first step took",
|
|
1065
|
+
performance.now() - startContextCanvas,
|
|
1066
|
+
"ms"
|
|
1067
|
+
);
|
|
1053
1068
|
const blankCanvas = doc.createElement("canvas");
|
|
1054
1069
|
blankCanvas.width = n2.width;
|
|
1055
1070
|
blankCanvas.height = n2.height;
|
|
@@ -1060,6 +1075,11 @@ function serializeElementNode(n2, options) {
|
|
|
1060
1075
|
if (canvasDataURL !== blankCanvasDataURL) {
|
|
1061
1076
|
attributes.rr_dataURL = canvasDataURL;
|
|
1062
1077
|
}
|
|
1078
|
+
console.log(
|
|
1079
|
+
"context canvas took",
|
|
1080
|
+
performance.now() - startContextCanvas,
|
|
1081
|
+
"ms"
|
|
1082
|
+
);
|
|
1063
1083
|
}
|
|
1064
1084
|
}
|
|
1065
1085
|
if (tagName === "img" && inlineImages) {
|
|
@@ -1149,6 +1169,7 @@ function serializeElementNode(n2, options) {
|
|
|
1149
1169
|
} catch (e2) {
|
|
1150
1170
|
}
|
|
1151
1171
|
const took = performance.now() - start;
|
|
1172
|
+
if (!window.serialization_perf_map) window.serialization_perf_map = {};
|
|
1152
1173
|
if (!(tagName in window.serialization_perf_map)) {
|
|
1153
1174
|
window.serialization_perf_map[tagName] = {
|
|
1154
1175
|
avg: 0,
|