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

Do not blit webgl canvas if width or height are zero #13140

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bokehjs/src/lib/models/canvas/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions bokehjs/test/unit/regressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
})
})
Loading