fabric-engine/JSSceneGraph — pull request #178 by jcgagnon (2012-02-18 13:20:10+00:00)
Title: Issue 174 - Obj not loading in FireFox

@phtaylor Hi Phil. **please read all** Finally the problem was not the file-based resource load node per say, but more the new event-based parsers. My guess is that this problem is on FireFox since a while (it was in 1.0.20 at least). What is happening is that on FireFox, as we knew since we had the problem before, small resources might get loaded instantly when they are small, which makes them somehow synchronous. The problem is that when it's synchronous like that, when we call addEventListener, the callback function might be called immediately, which caused problems in various cases here since the current Node is not even fully constructed, and the Node's own listeners are not even registered yet.

I fixed it in a way which I don't really like, which is:
- to make sure that everything is built when adding ourselve as a listener,
- when the event happens, register a boolean, so that if someone register too late we will call its own event just like if he didn't miss it

I don't really like that solution, because it is quite fragile, and it is only tested if it happens that on FireFox we have a small enough resource in the cache. Might be good enough for this release... A solution to this problem (which was used in XSI for other reasons) is to have a event suspending bracket, which might be restricted only to the currently built resource load node. If such a bracket is constructed (lower in the stack, like in sample's "html"), the load success events would be suspended until the end (destruction) of that bracket, ensuring that everything has been built meanwhile. Still not perfect solution however, but I'm not seeing many other. Using some sort of timers to delay the callback might work too, but might create problems too?

PS: I won't do more coding / investigation this weekend