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

Could FontLoader error and fileerror events trigger right away? #244

Open
danzen opened this issue Nov 2, 2017 · 3 comments
Open

Could FontLoader error and fileerror events trigger right away? #244

danzen opened this issue Nov 2, 2017 · 3 comments

Comments

@danzen
Copy link
Contributor

danzen commented Nov 2, 2017

It seems that if I have a broken font URL I see an error in the console right away but I am waiting the default 8 seconds for the error event to trigger. I might be wrong - but that seems to be what is happening. I could not get the fileerror event to trigger so this is using the error event. And I am just using a bad url to the font.

@lannymcnie
Copy link
Member

lannymcnie commented Nov 2, 2017

We don't load fonts as files. Instead we create CSS that triggers the font load in the browser, and then poll a canvas to determine when its loaded. Because of this, we do not receive the 404 error that the browser throws up.

There might be a way to do this by determining the font path, preloading it with XHR (as long as the domain supports CORS), and surfacing the 404 before doing the actual font preload -- but I am not sure how handy that would be, and it could load the font file twice (once in the browser cache and once for the XHR version).

Open to ideas....

@danzen
Copy link
Contributor Author

danzen commented Dec 16, 2017

What about a shorter timeout for fonts - so offer a fontTimeout (or whatever) parameter that defaults to 2 seconds as fonts would normally not take as long as images to load. Not sure if that is always the case but probably... Then if there are no traditional assets still loading and the fontTimeout has passed, trigger the error. I suppose we could separate out our font loads and set the default time to shorter, but we would not have to if CreateJS handled it.

@lannymcnie
Copy link
Member

Could be a reasonable solution.

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