Skip to content

Commit

Permalink
Remove onContext callbacks
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gervang <chris@gervang.com>
  • Loading branch information
chrisgervang committed Jun 20, 2024
1 parent f5f8072 commit 688f87f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
2 changes: 0 additions & 2 deletions docs/api-reference/core/device.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ Extends `DeviceProps`.
| `powerPreference` | `'high-performance'`| `'default'`, `'high-performance'`, `'low-power'` |
| `premultipliedAlpha?` | `true` | Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha. |
| `preserveDrawingBuffer?` | `false` | Default render target buffers will preserve their values until cleared or overwritten. Useful for screen capture. |
| `onContextLost` | `(event: Event) => void` | `webglcontextlost` event. |
| `onContextRestored` | `(event: Event) => void` | `webglcontextrestored` event. |
| `debug?: boolean` | `false` | WebGL API calls will be logged to the console and WebGL errors will generate JavaScript exceptions. |
| `break?: string[]` | `[]` | Insert a break point (`debugger`) if one of the listed gl functions is called. |
| `manageState?: boolean` | `true` | Set to false to disable WebGL state management instrumentation. |
Expand Down
5 changes: 0 additions & 5 deletions modules/core/src/adapter/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@ export type WebGLDeviceProps = _DeviceProps & {
spectorUrl?: string;

// ContextProps
onContextLost?: (event: Event) => void;
onContextRestored?: (event: Event) => void;
alpha?: boolean; // indicates if the canvas contains an alpha buffer.
depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.
stencil?: boolean; // Default render target has a stencil buffer of at least `8` bits.
Expand Down Expand Up @@ -304,9 +302,6 @@ export abstract class Device {
premultipliedAlpha: true,
preserveDrawingBuffer: false,

onContextLost: undefined!,
onContextRestored: undefined!,

debug: Boolean(log.get('debug')), // Instrument context (at the expense of performance)
break: (log.get('break') as string[]) || [],

Expand Down
6 changes: 2 additions & 4 deletions modules/webgl/src/adapter/webgl-device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,11 @@ export class WebGLDevice extends Device {

this.handle = createBrowserContext(this.canvasContext.canvas, {
...props,
onContextLost: (event: Event) => {
onContextLost: (event: Event) =>
this._resolveContextLost?.({
reason: 'destroyed',
message: 'Entered sleep mode, or too many apps or browser tabs are using the GPU.'
});
props.onContextLost?.(event);
}
})
});
this.gl = this.handle;

Expand Down

0 comments on commit 688f87f

Please sign in to comment.