Streamed PNG using URLStream intermittent when server is bogged

拈花ヽ惹草 提交于 2019-12-08 07:06:50

问题


So I used the regular loader class to load my images however the .close function is apparently broke in that class and it will not stop the download if it is called.

In my case I need to be able to cancel loading as the user could possibly be scrolling through alot of images and the if not canceled it can take a few minutes to catch up to the scroll position.

So after research the URLStream class seems to cure this problem and I found a good streaming class here

This class works very nice except when there is heavy load on the server causing lag.
When this lag happens the class will dispatch the complete event yet the image will not show.
Watching the download with HTTPFox shows the image in fact does get loaded.

I assume there is some kind of delayed issue with the URLStream class and the author of this class tried to correct it using the setTimeout method. I also tried delaying the dispatching of the complete event using a timer and not dispatching until if( this.width != 0 ) was detected and this seemed to work much better. But it is still haunting me just not as often.

Does anyone know of a fix for this or another solution for streaming PNGs and JPGs?


回答1:


I can see that there are some places in that code where conditions could be checked. But for a simple solution, it may be better to use a more developed system, like BulkLoader.



来源:https://stackoverflow.com/questions/8498419/streamed-png-using-urlstream-intermittent-when-server-is-bogged

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!