Skip to content

Commit d2f09ff

Browse files
WebGPURenderer: Remove error-reporting code unrelated to this PR.
These changes belong to mrdoob#33418 and were bundled into this branch by mistake. - Renderer.js: drop `onError` / `_onError` hook. - WebGPUBackend.js: drop `device.onuncapturederror` → `renderer.onError` bridge. - WebGPUPipelineUtils.js: revert to dev (removes pipeline-label error messages and `_reportShaderDiagnostics`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c71e440 commit d2f09ff

3 files changed

Lines changed: 5 additions & 162 deletions

File tree

src/renderers/common/Renderer.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -594,17 +594,6 @@ class Renderer {
594594
*/
595595
this.onDeviceLost = this._onDeviceLost;
596596

597-
/**
598-
* A callback function that defines what should happen when an uncaptured
599-
* backend error is reported (e.g. a WebGPU validation/out-of-memory/internal
600-
* error raised outside an error scope). Applications can override this to
601-
* surface errors in their own UI without letting them escalate to a device
602-
* loss. The default implementation logs to the console.
603-
*
604-
* @type {Function}
605-
*/
606-
this.onError = this._onError;
607-
608597
/**
609598
* Defines the type of output buffers. The default `HalfFloatType` is recommend for
610599
* best quality. To save memory and bandwidth, `UnsignedByteType` might be used.
@@ -1207,26 +1196,6 @@ class Renderer {
12071196

12081197
}
12091198

1210-
/**
1211-
* Default implementation of the uncaptured backend error callback.
1212-
*
1213-
* @private
1214-
* @param {Object} info - Information about the uncaptured error.
1215-
*/
1216-
_onError( info ) {
1217-
1218-
let errorMessage = `THREE.WebGPURenderer: Uncaptured ${ info.api } ${ info.type }`;
1219-
1220-
if ( info.message ) {
1221-
1222-
errorMessage += `: ${ info.message }`;
1223-
1224-
}
1225-
1226-
error( errorMessage );
1227-
1228-
}
1229-
12301199
/**
12311200
* Renders the given render bundle.
12321201
*

src/renderers/webgpu/WebGPUBackend.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,21 +288,6 @@ class WebGPUBackend extends Backend {
288288

289289
} );
290290

291-
device.onuncapturederror = ( event ) => {
292-
293-
const gpuError = event.error;
294-
const type = gpuError && gpuError.constructor ? gpuError.constructor.name : 'GPUError';
295-
const message = ( gpuError && gpuError.message ) || 'Unknown uncaptured GPU error';
296-
297-
renderer.onError( {
298-
api: 'WebGPU',
299-
type,
300-
message,
301-
originalEvent: event
302-
} );
303-
304-
};
305-
306291
this.device = device;
307292

308293
this.trackTimestamp = this.trackTimestamp && this.hasFeature( GPUFeatureName.TimestampQuery );

src/renderers/webgpu/utils/WebGPUPipelineUtils.js

Lines changed: 5 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
NeverStencilFunc, AlwaysStencilFunc, LessStencilFunc, LessEqualStencilFunc, EqualStencilFunc, GreaterEqualStencilFunc, GreaterStencilFunc, NotEqualStencilFunc
1616
} from '../../../constants.js';
1717

18-
import { error, ReversedDepthFuncs, warn, warnOnce } from '../../../utils.js';
18+
import { error, ReversedDepthFuncs, warnOnce } from '../../../utils.js';
1919

2020
/**
2121
* A WebGPU backend utility module for managing pipelines.
@@ -272,12 +272,6 @@ class WebGPUPipelineUtils {
272272

273273
device.pushErrorScope( 'validation' );
274274

275-
const stages = [
276-
{ program: vertexProgram, module: vertexModule.module },
277-
{ program: fragmentProgram, module: fragmentModule.module }
278-
];
279-
const pipelineLabel = pipelineDescriptor.label;
280-
281275
if ( promises === null ) {
282276

283277
pipelineData.pipeline = device.createRenderPipeline( pipelineDescriptor );
@@ -288,9 +282,7 @@ class WebGPUPipelineUtils {
288282

289283
pipelineData.error = true;
290284

291-
error( `WebGPURenderer: Render pipeline creation failed (${ pipelineLabel }): ${ err.message }` );
292-
293-
this._reportShaderDiagnostics( stages, pipelineLabel ).catch( () => {} );
285+
error( err.message );
294286

295287
}
296288

@@ -300,28 +292,19 @@ class WebGPUPipelineUtils {
300292

301293
const p = new Promise( async ( resolve /*, reject*/ ) => {
302294

303-
let asyncError = null;
304-
305295
try {
306296

307297
pipelineData.pipeline = await device.createRenderPipelineAsync( pipelineDescriptor );
308298

309-
} catch ( err ) {
310-
311-
asyncError = err;
312-
313-
}
299+
} catch ( err ) { }
314300

315301
const errorScope = await device.popErrorScope();
316302

317-
if ( errorScope !== null || asyncError !== null ) {
303+
if ( errorScope !== null ) {
318304

319305
pipelineData.error = true;
320306

321-
const reason = ( errorScope && errorScope.message ) || ( asyncError && asyncError.message ) || 'unknown';
322-
error( `WebGPURenderer: Async render pipeline creation failed (${ pipelineLabel }): ${ reason }` );
323-
324-
await this._reportShaderDiagnostics( stages, pipelineLabel );
307+
error( errorScope.message );
325308

326309
}
327310

@@ -390,107 +373,13 @@ class WebGPUPipelineUtils {
390373

391374
}
392375

393-
const computeStage = pipeline.computeProgram;
394-
const pipelineLabel = `computePipeline_${ computeStage.stage }${ computeStage.name ? `_${ computeStage.name }` : '' }`;
395-
396-
device.pushErrorScope( 'validation' );
397-
398376
pipelineGPU.pipeline = device.createComputePipeline( {
399-
label: pipelineLabel,
400377
compute: computeProgram,
401378
layout: device.createPipelineLayout( {
402379
bindGroupLayouts
403380
} )
404381
} );
405382

406-
device.popErrorScope().then( ( err ) => {
407-
408-
if ( err !== null ) {
409-
410-
pipelineGPU.error = true;
411-
412-
error( `WebGPURenderer: Compute pipeline creation failed (${ pipelineLabel }): ${ err.message }` );
413-
414-
this._reportShaderDiagnostics( [ { program: computeStage, module: computeProgram.module } ], pipelineLabel ).catch( () => {} );
415-
416-
}
417-
418-
} );
419-
420-
}
421-
422-
/**
423-
* Reads line-accurate diagnostics from shader modules and logs any
424-
* errors/warnings/info messages. Called from pipeline creation error paths
425-
* to turn opaque validation failures into actionable WGSL feedback.
426-
*
427-
* @private
428-
* @param {Array<{program: ProgrammableStage, module: GPUShaderModule}>} stages - Pairs of program + compiled shader module.
429-
* @param {string} pipelineLabel - Label of the owning pipeline, used as log prefix.
430-
* @return {Promise<void>}
431-
*/
432-
async _reportShaderDiagnostics( stages, pipelineLabel ) {
433-
434-
for ( const { program, module } of stages ) {
435-
436-
if ( ! module || typeof module.getCompilationInfo !== 'function' ) continue;
437-
438-
let info;
439-
440-
try {
441-
442-
info = await module.getCompilationInfo();
443-
444-
} catch ( _ ) {
445-
446-
continue;
447-
448-
}
449-
450-
if ( ! info || ! info.messages || info.messages.length === 0 ) continue;
451-
452-
const stageName = program ? program.stage : 'shader';
453-
const sourceLines = program && program.code ? program.code.split( '\n' ) : null;
454-
455-
for ( const msg of info.messages ) {
456-
457-
const location = ( msg.lineNum > 0 )
458-
? ` at line ${ msg.lineNum }${ msg.linePos > 0 ? `:${ msg.linePos }` : '' }`
459-
: '';
460-
461-
const header = `WebGPURenderer [${ pipelineLabel } / ${ stageName } ${ msg.type }]${ location }: ${ msg.message }`;
462-
463-
let excerpt = '';
464-
if ( sourceLines && msg.lineNum > 0 ) {
465-
466-
const line = sourceLines[ msg.lineNum - 1 ];
467-
if ( line !== undefined ) {
468-
469-
excerpt = `\n ${ line }`;
470-
if ( msg.linePos > 0 ) {
471-
472-
excerpt += `\n ${ ' '.repeat( Math.max( 0, msg.linePos - 1 ) ) }^`;
473-
474-
}
475-
476-
}
477-
478-
}
479-
480-
if ( msg.type === 'error' ) {
481-
482-
error( header + excerpt );
483-
484-
} else {
485-
486-
warn( header + excerpt );
487-
488-
}
489-
490-
}
491-
492-
}
493-
494383
}
495384

496385
/**

0 commit comments

Comments
 (0)