Tuesday, September 14, 2010

Eventually: Jangaron + Sound in Firefox 3.6

Greetings, programs, it's been quite a while.
Jangaron looks a bit abandoned, doesn't it? Well, you may be right. I've been working hard on the "parent" project Jangaroo and its Flash compatibility: see this new Flash-ported-to-Jangaroo Demo!
But nonetheless, I was quite annoyed when I noticed that Jangaron was not working correctly with Firefox 3.6. To be more precise, the mini game worked, and the settings UI worked, but starting the full game from the settings UI with sound enabled failed. The workaround was to
  1. play Jangaron mini only or
  2. switch off sound before starting the game from the UI.
Now that I found time to dig into the problem, the solution sounds somewhat familiar: browser detection was broken with Firefox 3.6! After patching that, everything now works fine again. So please spread the word to Firefox 3.6 users to go ahead and play Jangaron (again)!
The problem was in the browser detection code I copied back then from an old version of MooTools, which detects Gecko aka Firefox like so:
  if (window.document["getBoxObjectFor"] != null)
    return ENGINE_GECKO;

It is not really bad practice to use proprietary methods or properties to detect a browser, but as you can see in this case, it is not very future-safe. Because as browsers become more and more standards-compliant, especially these proprietary methods are likely to be removed (as in this case, see here). Or, as for example happened in case of Microsoft extensions like CONTENTEDITABLE, they are copied by other browsers, and thus also fail as a distinguishing criteria.
Whatsoever, since the only thing that came after GECKO was OPERA and UNKNOWN, I now ask for Opera first and consider everything else a Gecko and hope your exotic Linux browser won't mind.

3 comments:

  1. Glad to see this is still alive. Too bad it doesn't work on Chrome because that's my new browser of choice. BTW, what is the best browser to play? I use FF 3.6 for Jangatron and I have to really tweak the settings to get a playable framerate, usually between 4-10 fps.

    I have a pretty old 2.2Ghz laptop with a 16MB ATI Radeon onboard. I imagine I can't do much more about framerate with that; I've reduced my window size to as small as I can reasonably play.

    I wondered if turning off the floor would help?

    Anyway, awesome game. Keep up the good work.

    ReplyDelete
  2. Thanks for your feedback, Brian, my faithful program! :-)

    It doesn't work on Chrome? Let's figure out why, because it runs perfectly on my Chrome (latest final version, currently 6.0.472.59), and it's the fastest Jangaron experience ever. Please clear your cache, and if the settings UI appears at all, reset settings (old Cookie?). Sound is the source of many problems. Can you start the game without sound?
    If you can still reproduce the problem, please send me any JavaScript error details (Tools -> JavaScript Console), screen shots, whatever, to jangaron(AT)arcor.de!

    Firefox is actually the slowest browser regarding rendering performance. As you can see by resizing the window, JavaScript performance is not the bottleneck.

    I could add a switch for the floor animation, but you wouldn't feel your speed then and it wouldn't be fun, I'm afraid.

    What I should really try is to let Jangaron draw in SVG or Canvas if available. That could really be faster in Firefox!

    ReplyDelete
  3. Oh, duh. I had a Flash-blocking extension stopping the game from loading. There was no indication of a block, but still, I don't know why I didn't think of that. Not only does Jangaron work in Chome, it KICKS ASS in Chrome. I see why more of my friends are calling FireFox "FireFail".

    No need to turn off any of the features for performance. Man, this is awesome. I'm going to ruin my weekend for sure, haha.

    ReplyDelete

Note: Only a member of this blog may post a comment.