Skip to content

BlazorCanvas2d gradient error#6

Merged
Zettersten merged 1 commit intomainfrom
feature/blazorcanvas2d-gradient-error-3295
Jan 16, 2026
Merged

BlazorCanvas2d gradient error#6
Zettersten merged 1 commit intomainfrom
feature/blazorcanvas2d-gradient-error-3295

Conversation

@Zettersten
Copy link
Owner

Sanitize non-finite numeric arguments for canvas gradient creation methods in JS to prevent JSException crashes.

The Blazor demo was crashing due to Microsoft.JSInterop.JSException: Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': The provided double value is non-finite. This occurred when NaN or Infinity values were passed from .NET to JavaScript for gradient coordinates, causing the browser's canvas API to throw an error and halt the render loop. This fix coerces such non-finite numbers to 0 before invoking the canvas API.


Open in Cursor Open in Web

Co-authored-by: erik <erik@zettersten.com>
@cursor
Copy link

cursor bot commented Jan 15, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@Zettersten Zettersten marked this pull request as ready for review January 16, 2026 18:04
@Zettersten Zettersten merged commit 329d6e7 into main Jan 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants