Showing posts with label browser compatibility. Show all posts
Showing posts with label browser compatibility. Show all posts

Friday, October 29, 2010

Jangaron 0.71: fix for IE9 beta

Another new browser version needs another patch.
This time, it's IE9 beta: alas, it became too standards-compliant! Thus, a typical crude workaround needed for IE6/7/8 did not work anymore. I fixed it, so you can now enjoy Jangaron in Internet Explorer 9 (beta)! It's fast and it's fun!

Evaluation
In IE < 9, you will run into problems when trying to dynamically create an input field by code like this:
  var input = document.createElement("input");
  input.setAttribute("type", "radio");
Old IEs refuse to interpret the type, also if you set it as a JavaScript attribute. Thus, you are forced to use a proprietary, IE-specific API extension that allows to hand in HTML fragments instead of the element name:
// only works in IE < 9:
  var input = document.createElement("<input type='radio'>");
Unfortunately, the usual way to do feature detection instead of browser detection does not apply here, since the function createElement() is defined in any browser, only old IEs provide additional semantics. So I did browser detection (shame on me), which of course failed when IE 9 (note: only in IE 9 mode, not in any backwards-compatibility mode!) became standards-compliant.
The only way out was to use the anti-pattern programming by exceptions and simply try the extended API and catch the error for standards-compliant browsers. To avoid recurring runtime penalty, I only do this once and store the result in a feature flag:
  var SUPPORTS_CREATE_ELEMENT_WITH_ATTRIBUTES = function() {
    try {
      window.document.createElement("<input type='text'>");
      return true;
    } catch (e) {
      return false;
    }
  }();
Instead of SUPPORTS_... I should maybe call that flag REQUIRES_..., since I do not use this feature because it is supported, but because the way the standard suggests does not work in old IEs.

Thursday, July 3, 2008

Jangaron 0.52 in Firefox 3 -- but slow

About 20% of all Firefox surfers that have visited www.jangaron.net during the last month already used Firefox 3 -- and couldn't start the game! After a really small patch, Jangaron 0.52 now works completely in Firefox 3.
My workmate Jan found a bug in the browser abstraction code: To let standard-compatible browsers simulate IE behavior (yes, I know, it should be the other way round!), I checked whether MouseEvent is defined. Since MouseEvent is supposed to be a constructor function, I used typeof MouseEvent=="function". For reasons beyond my imagination, Firefox 3 changes the type of MouseEvent to "object", so the check failed. Now, I simply use typeof MouseEvent!="undefined".
After quick-fixing the bug (no new version number, just reload / maybe clear browser cache), the full game now works in Firefox 3. However... it runs unbearably slow :-(. I started searching for similar problems and found many disappointed Firefox users who reported that version 3 is actually quite slower than 2 (at least in certain circumstances).
Currently, there is not much more I can, or better am willing to do about it. Maybe the guys over at Mozilla will come up with some performance tips or patches soon. Until then, I do not recommend using Firefox 3 to play Jangaron. If you are brave and try, I would really be interested in your experience. By the way, I didn't yet bother to patch the "stable version" 0.43, which has the same bug, so please use 0.52 with Firefox 3.
One last hint, if you want to use Firefox 3 for surfing and Firefox 2 to play Jangaron: just google for "firefox.2 firefox.3 parallel". Essentially, you create a separate profile for each Firefox version so the other one does not mess it up, and start the program with command line switches that tell it a) to use a certain profile and b) not to reuse the running Firefox instance.
After being a bit disappointed by Firefox 3, Opera 9.5 and Internet Explorer 8 are my next candidates...

Wednesday, May 28, 2008

Fixed Flash detection for Opera / Wii

Some folks over at the Jangaron Tron-Sector thread reported that version 0.5 does not work in certain browsers and under certain circumstances.
The good news: I fixed a bug in my Flash detection code so that it now works in Opera without the right (and still without any) Flash plug-in. That fix (version 0.51) should make it work on the Wii, too ("work" in this case means "no sound, but at least you can play the game").
Concerning other browsers, some people seem to have tried IE6 and very old Safari versions which I cannot test, and both do not work. Let me quote from my own post over at Tron-Sector:
Jangaron is based on CSS border slants, which are not fully functional in IE6. One crucial feature, namely transparent borders, is missing in older IE versions, and Jangaron heavily relies on that feature.
Besides Firefox and IE7, there are many other alternative browsers that are supported by Jangaron: all other Gecko-based browsers should work (Iceweasel, Netscape, Camino, ...), Safari 3.1 (I think 3.0 also, but I am not sure) and other WebKit-based browsers, Opera 9.25 and thus the Wii browser. Unfortunately, there are still problems with browsers based on KHTML (the WebKit predecessor), like Konqueror 3.x. Jangaron's stable version seems to run on Konqueror 4, though, because some serious bugs in KHTML's JavaScript engine were fixed (or was it even replaced completely?).
Jangaron's claim "The Tron Lightcycle Game in any modern browser" is to be emphasized on modern, and is also rather a vision than a completely proven fact. I need help for testing and debugging Jangaron in this multitude of browsers, so all you JavaScript / DHTML gurus out there, feel welcome to support!
Thank you for starting to report problems; now, let's analyse and fix them if possible!