Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
fix(emulator): require debug ext for webgl params
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed May 3, 2023
1 parent 1f76899 commit ed5e43f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions agent/docs/BrowserContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Create a new [Page](./Page.md) in this context.
## Hooks

- onNewPage(page: [Page](./Page.md)): Promise<void> - Called before a new Page environment is allowed to load.
- onNewFrameProcess(frame: [Frame](./Frame.md)): Promise<void> - Called when a Frame is created in it's own process (oopif).
- onNewWorker(worker: [Worker](./Worker.md)): Promise<void> - Called before a new Worker environment is allowed to run.
- onDevtoolsPanelAttached(devtoolsSession: [DevtoolsSession](./DevtoolsSession.md)): Promise<any> - Called when a Devtools Panel attaches to this Browser.
- onDevtoolsPanelDetached(devtoolsSession: [DevtoolsSession](./DevtoolsSession.md)): Promise<any> - Called when a Devtools Panel closes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
proxyFunction(
const activatedDebugInfo = new WeakSet<WebGL2RenderingContext | WebGLRenderingContext>();

for (const context of [
self.WebGLRenderingContext.prototype,
'getParameter',
function (originalFunction, thisArg, argArray) {
const parameter = argArray && argArray.length ? argArray[0] : null;
// call api to make sure signature goes through
self.WebGL2RenderingContext.prototype,
]) {
proxyFunction(context, 'getExtension', function (originalFunction, thisArg, argArray) {
const result = Reflect.apply(originalFunction, thisArg, argArray);
if (args[parameter]) {
return args[parameter];
if (argArray?.[0] === 'WEBGL_debug_renderer_info') {
activatedDebugInfo.add(thisArg);
}

return result;
},
);
});

proxyFunction(
self.WebGL2RenderingContext.prototype,
'getParameter',
function (originalFunction, thisArg, argArray) {
// eslint-disable-next-line @typescript-eslint/no-loop-func
proxyFunction(context, 'getParameter', function (originalFunction, thisArg, argArray) {
const parameter = argArray && argArray.length ? argArray[0] : null;
// call api to make sure signature goes through
const result = Reflect.apply(originalFunction, thisArg, argArray);
if (args[parameter]) {
if (!result && !activatedDebugInfo.has(context)) {
return result;
}

return args[parameter];
}
return result;
},
);
});
}

0 comments on commit ed5e43f

Please sign in to comment.