Skip to content
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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Report WebGL errors #281

wants to merge 2 commits into from

Conversation

JannikGM
Copy link
Contributor

Hacky prototype for #280; expecting many changes before merge-ready

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(", ");
}
Copy link
Contributor Author

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') {
Copy link
Contributor Author

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;
Copy link
Contributor Author

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);
Copy link
Contributor Author

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);
}
});
Copy link
Contributor Author

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 = [];
Copy link
Contributor Author

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);
}
});
}
Copy link
Contributor Author

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

@sebavan sebavan marked this pull request as draft August 30, 2023 21:43
@sebavan
Copy link
Member

sebavan commented Aug 30, 2023

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.

@JannikGM
Copy link
Contributor Author

JannikGM commented Sep 4, 2023

I honestly never though of Spector to troubleshoot those kind of errors ...

This is a common feature of these API tracing tools / graphics debuggers.

... as most of the info are only available in browsers console.

I don't think I've seen this feature (GL error reporting in devtools) yet?
I only get such warnings from graphics middleware or when using external debugging tools.
However, I don't get it in a timeline like Spector.js provides (where I can see error reports interleaved with graphics output).

This would only provide a tiny subset of the errors

What other errors would there be, other than logic?

a huge perf [h]it

I don't think the perf hit is that bad (compared to dumping the framebuffer or textures).
However, I also think it should be an optional "Validate" or "Check for errors" checkbox for tracing.

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.

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).
Even if it's not 100% faithful to what the browser or driver might do, such implementations still follow the WebGL spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants