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

Center image does not render on first render in Safari #257

Open
Scooter1337 opened this issue Nov 11, 2024 · 2 comments
Open

Center image does not render on first render in Safari #257

Scooter1337 opened this issue Nov 11, 2024 · 2 comments

Comments

@Scooter1337
Copy link

Center image does not render on first render in Safari

I've tried with base64 to rule out any CORS issues etc, but it still does not work sadly.

@Scooter1337
Copy link
Author

Scooter1337 commented Nov 11, 2024

I seem to have kind of circumvented the issue very dirtily as follows:

const qrCode = ...;
await getRawData();

if (navigator.userAgent.indexOf("Safari") !== -1) {
      // weird bug where safari fails to render the image in the first call
      await new Promise((resolve) => setTimeout(resolve, 500));

      const qrCode = new QRCodeStyling({
        // ... reinstantiating class seems to be necessary
      });


      return (await qrCode.getRawData("png")) as Buffer | Blob;
    }

If I remove the setTimeout, it starts occurring again, same goes for the reinstantiated class

NOTE: lower values for the promise probably work too

@jackyef
Copy link

jackyef commented Dec 2, 2024

What worked for me was to simply do a .update({ data }) to trigger a redraw after the first draw finishes.

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