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

putImageData does not work on some safari version #43

Open
Lblenner opened this issue Jan 22, 2024 · 2 comments
Open

putImageData does not work on some safari version #43

Lblenner opened this issue Jan 22, 2024 · 2 comments

Comments

@Lblenner
Copy link

I'm using putImageData with the infinite canvas and the behavior is fine using most browser.
But on safari version 16.5 using Ventura 13.4, when a call to this function is made,
the console logs the following error and does not display the expected content.

Unhandled Promise Rejection: TypeError: Type error

The problem did not occur in other settings using safari.

I created this minimal project using svelte.
The component using the canvas is at src/routes/TestComponent.svelte.

On most platform, a pixelated heart is shown, using this function

const draw = () => {
    if (context && canvas) {
      context.clearRect(0, 0, canvas.width, canvas.height);

      const res = 21;
      console.log(content.length, res * res * 4);
      let imageData = new ImageData(res, res);
      imageData.data.set(content);

      // behaviour is different if this is used before
      // context.fillRect(0,0, 100,100)

      context.putImageData(
        imageData,
        Math.floor(canvas.width / 2),
        Math.floor(canvas.height / 2)
      );
    }
  };

Is there a problem with the way I use the library ?

I plan to create an example not using svelte, to make sure the problem is not from here.

@emilefokkema
Copy link
Owner

Internally, InfiniteCanvas uses createPattern to draw the ImageData. But, as it turns out, Safari has a bug in precisely that method. So, nothing I can do about this, unfortunately.

@Lblenner
Copy link
Author

okey, do you want me to keep the issue open to track potential changes in the behavior ?

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

No branches or pull requests

2 participants