sproutcore / sproutcore

JavaScript Application Framework - JS library only
sproutcore.com
Other
2.15k stars 291 forks source link

imageCache.releaseImage() calls undefined function #106

Closed bjwatson closed 13 years ago

bjwatson commented 13 years ago

I previously created this bug report as issue #92, but accidentally closed it when I added a comment, and see no obvious way to re-open it.

There appears to be a broken method call in frameworks/foundation/system/image_cache.js. SC.imageCache._unscheduleImageEntry() makes a call to queue.image.abort(), in which queue.image appears to be undefined.

This code path can be executed with:

var foo = function(url, imageOrError) { console.log('loaded image ' + url); } var url = SC.RunLoop.begin(); SC.imageCache.loadImage(url, null, foo); SC.RunLoop.end() SC.RunLoop.begin(); SC.imageCache.releaseImage(url, null, foo); SC.RunLoop.end()

This is a timing sensitive bug. If the releaseImage() call occurs while the image is actively loading, you will get "TypeError: Cannot call method 'abort' of undefined" on Chrome 7.0.517.41 for Mac OS 10.6.4. On Firefox 3.6.10 with Firebug 1.5.4 (same Mac platform), you get "TypeError: queue.image is undefined". I assume a similar error occurs on other browsers / platforms.

I tested this on Sproutcore 1.4.3.

I commented out the queue.image.abort() line as a workaround, which seems to work fine. I'm able to make forward progress on my application with this workaround. The purpose of this bug report is for the Sproutcore team to determine whether this line of code has any value, and if so, what should it really be?

Best regards, Brian

wagenet commented 13 years ago

Check for image before trying to abort - Closed by d0499f3309d7b7cbfedbaaa94ee86af7a87833be