From 4168fa0e9177152d87892c0cb7e79096c0b7377a Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Thu, 18 May 2023 17:29:09 +0100 Subject: [PATCH] Do not blit webgl canvas if width or height are zero --- bokehjs/src/lib/models/canvas/canvas.ts | 2 +- bokehjs/test/unit/regressions.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/bokehjs/src/lib/models/canvas/canvas.ts b/bokehjs/src/lib/models/canvas/canvas.ts index 73caa3fb7ed..9e4d99ec4fd 100644 --- a/bokehjs/src/lib/models/canvas/canvas.ts +++ b/bokehjs/src/lib/models/canvas/canvas.ts @@ -217,7 +217,7 @@ export class CanvasView extends UIElementView { blit_webgl(ctx: Context2d): void { // This should be called when the ctx has no state except the HIDPI transform const {webgl} = this - if (webgl != null) { + if (webgl != null && webgl.canvas.width*webgl.canvas.height > 0) { // Blit gl canvas into the 2D canvas. To do 1-on-1 blitting, we need // to remove the hidpi transform, then blit, then restore. // ctx.globalCompositeOperation = "source-over" -> OK; is the default diff --git a/bokehjs/test/unit/regressions.ts b/bokehjs/test/unit/regressions.ts index 7ead6f6ed7f..3989b41bad1 100644 --- a/bokehjs/test/unit/regressions.ts +++ b/bokehjs/test/unit/regressions.ts @@ -682,4 +682,22 @@ describe("Bug", () => { ]) }) }) + + describe("in issue #13139", () => { + function make_plot(width: number, height: number) { + const p = fig([width, height], {output_backend: "webgl"}) + p.line([0, 1], [0, 1]) + return p + } + + it("raises DOMException if webgl canvas width is zero", async () => { + await display(make_plot(0, 100)) + }) + it("raises DOMException if webgl canvas height is zero", async () => { + await display(make_plot(100, 0)) + }) + it("raises DOMException if webgl canvas area is zero", async () => { + await display(make_plot(0, 0)) + }) + }) })