-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report WebGL errors #281
base: master
Are you sure you want to change the base?
Report WebGL errors #281
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const canvas = document.getElementById("renderCanvas"); | ||
const gl = canvas.getContext("webgl"); | ||
|
||
function loop() { | ||
gl.clearColor(0.3, 0.3, 0.3, 1.0); // Clear to black, fully opaque | ||
gl.clearDepth(1.0); // Clear everything | ||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) | ||
|
||
console.log(gl.getError(), "before") | ||
gl.clear(0xFFFF) | ||
console.log(gl.getError(), "after") | ||
|
||
window.requestAnimationFrame(function() { | ||
loop(); | ||
}); | ||
} | ||
loop(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,13 +113,41 @@ export class CommandSpy { | |
// tslint:disable-next-line:only-arrow-functions | ||
return function () { | ||
const before = Time.now; | ||
const result = OriginFunctionHelper.executeOriginFunction(self.spiedCommandRunningContext, self.spiedCommandName, arguments); | ||
let result = OriginFunctionHelper.executeOriginFunction(self.spiedCommandRunningContext, self.spiedCommandName, arguments); | ||
const after = Time.now; | ||
|
||
const functionInformation = { | ||
// Initialize error logging | ||
const gl = self.spiedCommandRunningContext; | ||
if (!gl.currentErrors) { | ||
gl.currentErrors = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This information should be stored elsewhere; where? |
||
} | ||
|
||
const newErrors = [] | ||
if (self.spiedCommandName === 'getError') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very hacky way to check for this? |
||
// Inject one of the collected errors | ||
result = gl.currentErrors.shift() ?? gl.NO_ERROR; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
How do I do that? |
||
} else { | ||
// Record new errors | ||
while (true) { | ||
const errorResult = OriginFunctionHelper.executeOriginFunction(gl, "getError", undefined); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There might be a nicer way to run this; I'm also unsure about |
||
if (errorResult === gl.NO_ERROR) { | ||
break; | ||
} | ||
newErrors.push(errorResult); | ||
} | ||
// Move new errors to the accumulated list | ||
newErrors.forEach(newError => { | ||
if (!gl.currentErrors.includes(newError)) { | ||
gl.currentErrors.push(newError); | ||
} | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might break in which order the errors are being returned, because it avoids duplicates. However, this is implementation defined. I'm also generally not sure if this complicated FIFO for handling multiple errors is necessary. |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This entire error handling might have to live elsewhere / it should at least move into a separate function |
||
|
||
const functionInformation: IFunctionInformation = { | ||
name: self.spiedCommandName, | ||
arguments, | ||
result, | ||
errors: newErrors, | ||
startTime: before, | ||
endTime: after, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a poor way of displaying this (the same goes for how the return value gets displayed.. this should be formatted in the frontend / not in the backend)