vercel / satori

Enlightened library to convert HTML and CSS to SVG
https://og-playground.vercel.app
Mozilla Public License 2.0
11.14k stars 251 forks source link

Cannot read properties of undefined (reading '265') #649

Open shinyuna opened 4 days ago

shinyuna commented 4 days ago

Description / Observed Behavior

image

When using the Satori library, approximately 1 out of every 2 attempts fails to generate an SVG, throwing the following error: Cannot read properties of undefined (reading '265').

Expected Behavior Satori should generate the SVG consistently without encountering this error.

Reproduction

  1. npm run dev
  2. Enter URL : https://pfk83h-3000.csb.app/api/og

Additional Context

Satori version: 0.12.0 Configuration details:

This issue might be related to the dynamic asset loading process, as the error occurs sporadically.

shinyuna commented 4 days ago
image

I think there is a problem with this dependency.

erxclau commented 1 day ago

Hey @shinyuna, the error you're running into seems similar to the error in https://github.com/vercel/satori/issues/162. Are you loading variable fonts? If not, would you be able to provide a reproduction?

shinyuna commented 19 hours ago

Hey @shinyuna, the error you're running into seems similar to the error in #162. Are you loading variable fonts? If not, would you be able to provide a reproduction?안녕하세요 @shinyuna, 발생한 오류는 #162의 오류와 유사한 것 같습니다. 가변 글꼴을 로드하고 있습니까? 그렇지 않다면 복제품을 제공할 수 있습니까?

I do not use variable fonts. Here is the reproduction! https://codesandbox.io/p/devbox/pfk83h

image

You can see the same error here.

  1. npm run dev
  2. enter preview url https://pfk83h-3000.csb.app/api/og

image

erxclau commented 11 hours ago

@shinyuna The three Noto Sans font files you are using are actually variable fonts, at least according to Google Fonts.

Screenshot 2024-11-28 at 2 45 03 PM

I think variable fonts essentially include all of the different font weights for a typeface into a single file. To fix this, you can download a specific font weight version from Google Fonts.

For example, when I download Noto_Sans_SC from Google Fonts, I get a static folder that includes all of the various font weights:

Screenshot 2024-11-28 at 2 47 35 PM

I was able to generate this image after changing from variable fonts to a regular static font:

Screenshot 2024-11-28 at 2 50 23 PM

Here is my fork of the reproduction: https://codesandbox.io/p/devbox/satori-forked-9m7ypl