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
Conversation
let stringified = this.spiedCommandName; | ||
if (args && args.length > 0) { | ||
stringified += ": " + this.stringifyArgs(args).join(", "); | ||
} | ||
if (result !== undefined && result !== null) { | ||
stringified += " -> " + this.stringifyResult(result); | ||
} | ||
if (errors.length > 0) { | ||
stringified += " ~> " + errors.map(error => this.stringifyValue(error)).join(", "); | ||
} |
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)
} | ||
|
||
const newErrors = [] | ||
if (self.spiedCommandName === 'getError') { |
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.
Very hacky way to check for this?
const newErrors = [] | ||
if (self.spiedCommandName === 'getError') { | ||
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
gl.NO_ERROR
might have been modified by the application. Ideally I'd be using something similar to OriginFunctionHelper.executeOriginFunction
to get the original constant.
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 comment
The 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 undefined
for IArguments
but wasn't sure how to make this work otherwise.
if (!gl.currentErrors.includes(newError)) { | ||
gl.currentErrors.push(newError); | ||
} | ||
}); |
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 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.
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
This information should be stored elsewhere; where?
gl.currentErrors.push(newError); | ||
} | ||
}); | ||
} |
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 entire error handling might have to live elsewhere / it should at least move into a separate function
Let me move as draft for now. I honestly never though of Spector to troubleshoot those kind of errors as most of the info are only available in browsers console. This would only provide a tiny subset of the errors at the expense of a huge perf it plus modifying the app flow by consuming the error on our side which might have weird unexpected side effects with the app thinking it is all good. |
This is a common feature of these API tracing tools / graphics debuggers.
I don't think I've seen this feature (GL error reporting in devtools) yet?
What other errors would there be, other than logic?
I don't think the perf hit is that bad (compared to dumping the framebuffer or textures).
There's actually a Khronos reference implementation for a feature like this: https://www.khronos.org/webgl/wiki/Debugging#Programmatically_Debugging_WebGL_applications (which my implementation doesn't follow). |
Hacky prototype for #280; expecting many changes before merge-ready