Skip to content

Commit 322634f

Browse files
authored
Limit array buffer tracing in TRACE_WEBGL_CALLS (#24776)
It seems like a recent change to chrome means that error logging is now sent to stderr, which means certain browser tests that use `TRACE_WEBGL_CALLS` are hitting the 50mb log limit in circleCI. Better to avoid logging huge array buffers.
1 parent 90250aa commit 322634f

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/lib/libwebgl.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -663,12 +663,24 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
663663
var contextHandle = glCtx.canvas.GLctxObject.handle;
664664
glCtx[f] = function(...args) {
665665
var ret = orig.apply(this, args);
666-
// Some GL functions take a view of the entire linear memory. Replace
667-
// such arguments with the string 'HEAP' to avoid serializing all of
668-
// memory.
669666
for (var i in args) {
670-
if (ArrayBuffer.isView(args[i]) && args[i].byteLength === HEAPU8.byteLength) {
671-
args[i] = 'HEAP';
667+
if (ArrayBuffer.isView(args[i])) {
668+
// Some GL functions take a view of the entire linear memory. Replace
669+
// such arguments with the string 'HEAP' to avoid serializing all of
670+
// memory.
671+
if (args[i].byteLength === HEAPU8.byteLength) {
672+
args[i] = 'HEAP';
673+
continue;
674+
}
675+
// For large arrays just take the first N elements.
676+
const MAX_ARRAY_ELEMS = 30;
677+
if (args[i].length > MAX_ARRAY_ELEMS) {
678+
const notShown = args[i].length - MAX_ARRAY_ELEMS;
679+
args[i] = args[i].subarray(0, MAX_ARRAY_ELEMS);
680+
args[i] = `[${args[i]}, ... <${notShown} more elements not shown>]`;
681+
} else {
682+
args[i] = `[${args[i]}]`;
683+
}
672684
}
673685
}
674686
#if PTHREADS

0 commit comments

Comments
 (0)