Skip to content

Commit f8f4218

Browse files
committed
Merge branch 'nk/minor-tweak' into 'master'
Return null when gl context not available instead of crashing See merge request arction/lcjs/lcjs-headless!2
2 parents 2d01298 + d3fa95f commit f8f4218

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ dom.window.HTMLCanvasElement.prototype.getContext = function () {
3333
if (arguments[0] === 'webgl') {
3434
// create headless-gl GL context
3535
const ctx: ReturnType<typeof createContext> & Partial<StackGlResize> = createContext(1, 1, arguments[1])
36+
if (!ctx) {
37+
return ctx
38+
}
3639
// insert the resize method to the context so that lcjs package can use it
3740
ctx.resize = ctx.getExtension('STACKGL_resize_drawingbuffer').resize
3841
return ctx

0 commit comments

Comments
 (0)