Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Preloading error with canvas project on first load with a large spritesheet file

Explorer ,
Dec 05, 2019 Dec 05, 2019

I made a canvas project with Animate 2020 (createjs 1.0.0), put it on my server, and I get an error during loading, so the project does not start.
This happens each time on the first load, when I refresh the page, with a second load everything works fine withour errors.
The project uses a large atlas file for the images (9MB). When I'm not using a spritesheet (so all image assets exported in individual files) I don't have the error, but then of course the loading takes much much longer.

 

Any idea what I can do to resolve this?

 

This is the error I'm getting:

Uncaught TypeError: Cannot read property 'getContext' of undefined
at a.b._parseData (createjs.min.js:12)
at new a (createjs.min.js:12)
at handleComplete ((index):51)
at (index):36
at a.b._dispatchEvent (createjs.min.js:12)
at a.b._dispatchEvent (createjs.min.js:12)
at a.b.dispatchEvent (createjs.min.js:12)
at a.b._sendComplete (createjs.min.js:16)
at a.b._loadNext (createjs.min.js:17)
at a.b._processFinishedLoad (createjs.min.js:17)

TOPICS
Error
2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 10, 2019 Dec 10, 2019

Default timeout for loading individual assets is 8 seconds.

 

https://createjs.com/docs/preloadjs/classes/LoadItem.html#property_loadTimeout

 

If one or more of your assets is taking longer than 8 seconds to load, that's probably what's causing the page to fail. Also your page is loading too much and is going to be a bad user experience.

 

There appears to be no official way to specify a longer timeout, so to extend the timeout period you'll have to manually hack up your generated code. The simp

...
Translate
Explorer ,
Dec 06, 2019 Dec 06, 2019

The problem is simple to reproduce when working with large PNGs. 

Example: make a canvas project 800x600. Put 2 large PNGs on the scene (for example 1000x1000) and publish with using a spritesheet.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 10, 2019 Dec 10, 2019

I swithched back to CC2019 but the problem was already there too. It's a frustrating that a simple thing like this does not work

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 10, 2019 Dec 10, 2019

Default timeout for loading individual assets is 8 seconds.

 

https://createjs.com/docs/preloadjs/classes/LoadItem.html#property_loadTimeout

 

If one or more of your assets is taking longer than 8 seconds to load, that's probably what's causing the page to fail. Also your page is loading too much and is going to be a bad user experience.

 

There appears to be no official way to specify a longer timeout, so to extend the timeout period you'll have to manually hack up your generated code. The simplest way appears to be to increase the default timeout. In the libs/createjs file, search for LOAD_TIMEOUT_DEFAULT=8e3. The "8e3" is 8000 written using engineering notation. The 8000 is milliseconds, or 8 seconds. Change the 3 to 4. This gives you an 80-second timeout per asset. The createjs file is overwritten every time you publish, so keep a backup copy of the modified version.

 

This is not guaranteed to work, it's just a suggestion.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 11, 2019 Dec 11, 2019

Thank you so much! Changing that timeout value does solve my problem!

(oh how I miss the Flash preloaders 😉 )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 03, 2021 May 03, 2021

I just came across this issue as well.

It appears that the easiest solution is to update the following auto-generated line of code in the html file from

var loader = new createjs.LoadQueue(false);
to
var loader = new createjs.LoadQueue(true);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 10, 2025 Jun 10, 2025
LATEST

I'm also looking a way to modify the LoadQueue from the default value false to true.
The template variable $CREATE_LOADER is handling this (creating 5 lines of code) but i cannot find a way to change the default 😞 





Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines