[Fling] Asset.timeout
Chris Allen
mrchrisallen at gmail.com
Tue Jun 13 11:26:56 EDT 2006
Hi Guys,
Grant reported a bug with the SoundAsset today. It doesn't broadcast
the error event when it fails to load.
Here is the transcript of the conversation I had with John to solve
the problem. Please send me your thoughts on this solution.
-Chris
--------------------
status
10:55
NEORILEY7 joined the chat
Chris Allen (AIM)
10:55
hi
NEORILEY7 (AIM)
10:55
he's been invited
Chris Allen (AIM)
10:55
ok
NEORILEY7 (AIM)
10:55
but he's not acceptatged
Chris Allen (AIM)
10:56
he's asleep
10:56
anyway
NEORILEY7 (AIM)
10:56
LOL
Chris Allen (AIM)
10:56
he can catch up here in a sec
NEORILEY7 (AIM)
10:56
ok
Chris Allen (AIM)
10:56
so the thing is
10:56
that SoundAsset fails silently
NEORILEY7 (AIM)
10:56
ok
10:56
so
10:57
if the asset isn't there (either external or in lib) it fails silently
and the load fails
10:57
but you never know about it, right?
Chris Allen (AIM)
10:57
correct
10:57
and the success boolean
10:57
that's passed in
10:57
well it just doesn't work like XML
NEORILEY7 (AIM)
10:57
ah right
Chris Allen (AIM)
10:58
sound = new Sound(target);
sound.onLoad = Delegate.create(this, handleLoad);
10:58
and
10:58
private function handleLoad(success:Boolean):Void
{
if (success)
{
NEORILEY7 (AIM)
10:58
right
Chris Allen (AIM)
10:58
success only happens if it finds the file
NEORILEY7 (AIM)
10:58
so, success comes back true?
Chris Allen (AIM)
10:58
yes
NEORILEY7 (AIM)
10:58
ah right
10:58
of course
Chris Allen (AIM)
10:58
but only if it finds the file
10:58
otherwise
NEORILEY7 (AIM)
10:58
ok, well, the way we should do it
Chris Allen (AIM)
10:58
it never gets triggered
NEORILEY7 (AIM)
10:58
is completely with bitesLoaded/total
10:59
we shouldn't even look at the onLoad for sound
10:59
and then apply a timeout option to the assets
Chris Allen (AIM)
10:59
right
10:59
that's what I was thinking
10:59
timeout
NEORILEY7 (AIM)
10:59
I had mentioned 2
10:59
timeouts
Chris Allen (AIM)
10:59
ok
10:59
which are
NEORILEY7 (AIM)
10:59
1. timeout trying to "get" the file
10:59
which is what we're talking about
11:00
2. timeout loading it: IE: you've found the file, it DID start
loading, but shit, it's taking tooooo long, abort after X amount of
time
Chris Allen (AIM)
11:00
ok
NEORILEY7 (AIM)
11:00
this of course, would be on "non-critical" files, but that's up to the author
Chris Allen (AIM)
11:00
well that's the same thing in this case right?
NEORILEY7 (AIM)
11:00
I guess it is
11:01
from what you've described
11:01
I'd have to say so
11:01
but then again, maybe the success flag is eronius
Chris Allen (AIM)
11:01
yeah
11:01
seems pointless
11:02
gotta love Flash
11:02
well so much for a group chat
NEORILEY7 (AIM)
11:02
haha
11:02
that's cool
11:02
the aim chat is a nice break from google
11:03
anyway, yeah we never look at that in the blitz framework
11:03
it's all bytes total/loaded and that's it
Chris Allen (AIM)
11:03
ok
11:03
well we can keep it
11:03
of course
11:03
but should also have this time out thing
NEORILEY7 (AIM)
11:03
well, I don't really like it
11:03
mixing 2 ways to check for loading, I think it introducing confusion
Chris Allen (AIM)
11:04
nahh
11:04
it's not confusing
NEORILEY7 (AIM)
11:04
meaning: I don't like having the onLoad check since it's not as reliable
Chris Allen (AIM)
11:04
hmm
11:04
well if it does load
11:04
then that is the only way to tell right?
NEORILEY7 (AIM)
11:05
well no, you check bytesTotal/loaded
Chris Allen (AIM)
11:05
ahh
11:05
yeah
11:05
ok
NEORILEY7 (AIM)
11:05
I think it's consistent across the board with all assets
11:05
that's all I'm saying
Chris Allen (AIM)
11:05
well too bad Grant isn't here to hear this
NEORILEY7 (AIM)
11:05
its a single process for checking load
Chris Allen (AIM)
11:05
as he's going to implement it
11:05
ok
11:06
well iwth XML it IS reliable
11:06
so we can leave that one alone I suppose
11:06
anywa
11:06
it should be transparent to the user
11:07
so shouldn't make a difference
NEORILEY7 (AIM)
11:07
ok, the question I have about xml is
11:07
aren't we still checking bytesloaded/total for that in the complete
download percentage?
11:07
I agree, though, it IS reliable
11:08
just a question really
Chris Allen (AIM)
11:08
yeah
11:08
we are
11:08
that's the only way to broadcast the loading status
11:08
so
11:09
I think we should add a timeout property to the Asset interface
11:09
getTiemout():Number; and setTiemOut(timeout:Number);
11:09
(spelled correctly of course)
11:10
NEORILEY7 (AIM)
11:10
haha of course !
11:10
Chris Allen (AIM)
11:10
we should have a default value
NEORILEY7 (AIM)
11:10
ok, what about the 2 timeouts?
Chris Allen (AIM)
11:10
thoughts on that?
11:10
oh yeah
NEORILEY7 (AIM)
11:10
yes, we should have something like a 10second timeout
Chris Allen (AIM)
11:10
should we really create two?
NEORILEY7 (AIM)
11:10
well yeah
11:11
absolutely
Chris Allen (AIM)
11:11
it just adds more confusion to the interface
NEORILEY7 (AIM)
11:11
you wouldn't want a site to fail because of an mp3 not loading
Chris Allen (AIM)
11:11
that's at the AssetLoader level IMO
11:11
but I see your point
NEORILEY7 (AIM)
11:11
well, consider that your site might fail entirely then
11:12
like if you load home.news.archives
Chris Allen (AIM)
11:12
well
11:12
I was thinking
NEORILEY7 (AIM)
11:12
and archives has an mp3 that fails
11:12
then the entire section fails?
Chris Allen (AIM)
11:12
that AssetLoader could have a flag
11:12
that says
11:12
continueOnLoadError
NEORILEY7 (AIM)
11:12
but what does that mean?
Chris Allen (AIM)
11:12
if that's true then it continues
11:12
loading the other assets
NEORILEY7 (AIM)
11:13
ok, let me understand then
11:13
so
11:13
you have a timeout setting
11:13
for a load
11:13
that's say, 10seconds
Chris Allen (AIM)
11:13
yep
NEORILEY7 (AIM)
11:13
then, if one of the peices times out individually, you throw the
error, check the flag continueOnLoadError
Chris Allen (AIM)
11:13
yep
NEORILEY7 (AIM)
11:13
if true, then you remove the offending asset from the load, and readjust stuff
11:14
ok, initially this sounds cool to me
11:14
and I like it over 2 timers
Chris Allen (AIM)
11:14
me too
NEORILEY7 (AIM)
11:14
cause I agree, the 2 timers is confusing
11:14
so, the timer is exclusively
11:14
for what then?
11:14
how long it takes to get "some bytes"?
Chris Allen (AIM)
11:15
nahh
NEORILEY7 (AIM)
11:15
but then if it gets some bytes, then it never fails?
Chris Allen (AIM)
11:15
I timeout after the load() method is called
11:15
period
NEORILEY7 (AIM)
11:15
but that's only applicable to the sound object in this instance yes?
Chris Allen (AIM)
11:15
no
NEORILEY7 (AIM)
11:15
xml load doesn't fire until all bytesLoaded
11:15
right?
Chris Allen (AIM)
11:15
that would work for XML too
NEORILEY7 (AIM)
11:16
I thought XML.data worked that way, not XML.load
Chris Allen (AIM)
11:16
no not XML.load()
11:16
Asset.load()
NEORILEY7 (AIM)
11:16
huh?
Chris Allen (AIM)
11:16
haha
11:16
ok
NEORILEY7 (AIM)
11:16
so wait how does that work
11:16
if one asset
Chris Allen (AIM)
11:16
Asset.load() gets called
NEORILEY7 (AIM)
11:16
is 1mb
11:16
and another is 20k
11:16
they both get 10 seconds to load?
Chris Allen (AIM)
11:16
inside that method you call the startTimer
NEORILEY7 (AIM)
11:16
ok
Chris Allen (AIM)
11:17
well that 10 sec
11:17
is still probably ok
11:17
although we may want to up that value for default
11:17
maybe 20 sec
11:18
at some point it's up to the developer using the library to make good
decisions on how to use it
NEORILEY7 (AIM)
11:18
I think
11:19
the timer, should be restarted when bytesLoaded changes
Chris Allen (AIM)
11:19
that would include creating proper timeout values
11:19
for really big stuff
11:19
ahh interesting idea
NEORILEY7 (AIM)
11:19
because, you'll never be able to compensate for the web
11:19
I mean, you might guess a DL time of X, but in reality, you can't
predict the path
11:19
etc, so I think tthat's more reasonable
Chris Allen (AIM)
11:19
ok
NEORILEY7 (AIM)
11:19
resetting the timer
Chris Allen (AIM)
11:20
that makes sense to me
NEORILEY7 (AIM)
11:20
if it keeps breaking the buffer
11:20
(timeout), then you know it's better to drop it
11:20
yeah cool
11:20
I think thats a solid solution
Chris Allen (AIM)
11:20
ok
NEORILEY7 (AIM)
11:20
1 timer, fits all
Chris Allen (AIM)
11:20
sounds good to me
NEORILEY7 (AIM)
11:20
i like it very much
Chris Allen (AIM)
11:20
I'm going to send this chat transcript to the list
NEORILEY7 (AIM)
11:21
sweet, yeah that'd be good to flush out
Chris Allen (AIM)
11:21
ok
11:21
as Grant needs this fixed right away, maybe he can implement it
NEORILEY7 (AIM)
11:21
yeah that'd be good
More information about the Fling
mailing list