Showing posts with label bug fix. Show all posts
Showing posts with label bug fix. 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.

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.

Sunday, August 3, 2008

Jangaroo Released and Jangaron Updated to 0.54

It's been a while since you last heard of me. Of course, I've been really busy, but rather less with Jangaron itself (and, as obvious, even less with the Jangaron Blog) than with the base technology Jangaroo.
Jangaroo? As mentioned before, Jangaron is completely written in JavaScript, but it uses features of the new language version JavaScript 2, most notably packages, classes, and static and private members. To allow this JavaScript 2 code to run in today's browsers, I use the Jangaroo compiler, which was developed by CoreMedia as an internal tool, but has just now been released to the public as Open Source. Guess what kept me busy: I was the initiator and so-called "Program Manager" of the project at CoreMedia, with the goal to launch the Open Source Jangaroo project. (Okay, plus one week holiday, where I refrained from touching a computer. To be honest, I lost a bet with my wife.)
Read all about the goal, features, and history of Jangaroo in the Jangaroo Blog.
What I did update for Jangaron are two things: I used the latest version of the Jangaroo compiler, and I revamped the settings UI. Read about both changes in a minute, but if you want to try the new version immediately, here are some hints for troubleshooting:
If you have any JavaScript errors, try to clear the browser cache. If that still does not help, reset your settings by clicking the corresponding button with the red x in the settings UI. If that does not work, either, delete the Cookie "jangaron" from domain "www.jangaron.net", path "/jangaron0.5" using a Cookie manager for your browser. If your browser does not have a Cookie manager, then don't use IE (well, you can still delete the Cookie from the file system). If you still have problems with the 0.54 update, please report back by comment or using the e-mail address given on the "About" tab of the game. For the time being, you can still use my back-up of version 0.52 or the (very old) stable version. I also updated Jangaron mini in the Blog, so here, clearing your browser may also make problems go away.

Updated to the Latest Jangaroo Compiler
I used the latest version of the compiler (version 0.1.1, which has just not yet been released) to recompile the Jangaron code. Besides some performance improvements, the main point is an even better browser compatibility of the Jangaroo runtime. This makes Jangaron run in Konqueror 3.x (tested with 3.4) and even on... yes... Safari/iPhone!!! It seems that Safari/iPhone is more similar to Konqueror/KHTML than to Safari/Desktop. Unfortunately, the way Jangaron grabs key strokes does not seem to work on Konqueror, and the iPhone does not even have (many) keys. So I set up a special iPhone version that uses on-screen buttons for turning. Speed and view control are not yet available, this is just a quick test whether it is playable at all. Please report back!
But most importantly, Jangaroo being Open Source allows me to release Jangaron as Open Source soon, too. I had to wait until Jangaroo was released, because nobody would have been able to produce a running version from the Jangaron source code without the Jangaroo compiler! Now, I have to figure out which license I'm going to use for Jangaron and where to put the source code repository. Developers, stay tuned!

Revamped the Settings User Interface
On my way from Hamburg to Augsburg to visit the 40th birthday party of a good friend of mine, I used the 2 x 6 hours to revamp Jangaron's settings UI and add a splash screen with a new logo including a smoothly increasing glow effect (again, pure JavaScript!).
To come back to the new features, the settings dialog now has
  • a large glowing lightcycle changing to the first user player's color and serving as the new "Enter the Grid" button,
  • a different color theme,
  • expandable, overhauled help texts for each tab,
  • it starts on the "Players" tab when visiting for the first time (since there you find the setting you most likely want to change),
  • there, it starts with the main two settings: game mode and number of players, and
  • in the background is now an optionally animated game grid (what else?), that can be switched on in the "Grid settings" tab. However, by default it is switched off, since the permanent redraw consumes quite some CPU. Also, you can get dizzy in the head from staring at the sliding grid.
One small visual change to the game is that the you win / you lose texts now even more look like old character-based terminal output. I added a PNG as an overlay that is slightly less transparent at every other line, which leads to this "analog monitor blur" font effect. You may need to take a closer look to recognize the difference (click the image above or lose the game, whatever you think is the faster option!), but still I think it was worth the effort since it adds to the 80-s look-and-feel of the game.

Of course, I also fixed some bugs. For example, combo box selections did not update correctly in Safari. Fortunately, someone else had identified and solved the problem before. The point is that Safari is very close to the spec here, which does not allow two options of a select element to be selected at the same time. So to select a different option, you have to deselect the currently selected one first, or the change is ignored in Safari. The fix was to simply use the selectIndex property of the select element, which avoids this problem completely.

Finally, you may ask yourself, and what about the 3rd person perspective? I have also been working on that, but there are still some performance issues in some browsers and some minor bugs and features (e.g. changing camera position), and I want to give you a good experience from the start when introducing that feature. Maybe I'll set up an alpha version of Jangaron 0.6 for curious and brave Jangaron fans, so let me know if you want me to!

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!

Friday, April 18, 2008

Multiplayer fixed

Zaphod tried to run in several equally decisive directions simultaneously. "Right!" he said. "Er ... we've got to get manual control of this ship."

"Can you fly her?" asked Ford pleasantly.

"No, can you?"

"No."

"Trillian, can you?"

"No."

"Fine," said Zaphod, relaxing. "We'll do it together."


Sorry, users, since some minor modifications to Jangaron for the "mini" version, multiplayer was broken! Both player views were rendered, but only one could be controlled, independent of key assignment.
The reason was a stupid bug: In the switch statement for key control, I wrote
case keyMap.slower: [...]; break;
otherwise: return true;
What I meant was:
case keyMap.slower: ...; break;
default: return true;
But unfortunately, the erroneous otherwise was interpreted as a label (a JavaScript language construct I never use!), so no error was raised, but return true was never executed! This led to the first player swallowing all key presses.
Of course I fixed the problem as soon as I noticed it. Since it was only a minor patch, I did not increase the version number.
You should know that Jangaron is a hobby project. There is no quality assurance, just some basic testing, and there are not yet any real "releases". This is why I need you! If anything does not work or looks awful or is unusable, or if you have any other feed-back, let me know!
So now, please go ahead and play Jangaron with two or more users! Believe me, it's much more fun than against programs.

Monday, March 31, 2008

Came from Alabama with a laptop on my knee

Ooops -- last night, I encountered an embarrassing bug in Jangaron: If you chose the same color for multiple players, a crash of one of them claimed the lives of all same-colored players!
I found the bug when trying to reconstruct the original scene from the movie, where all good players feature slightly different red/orange/something colors, while the bad guys are uniformed with blue light cycles. Not too bad, to get rid of all bad guys by crashing one of them, but not too fair, either (hey, good guys always have to be fair, but at least they don't have to brag about their ingenious plan to rule the world until eventually, they are fragged...). Another thing I noticed was that I really have to add a team mode.
Of course, I fixed the bug as soon as I could, i.e. on my way to work. Although I don't live in Alabama, riding public transport trains with my laptop (well, the company's laptop) gives my the opportunity to code on Jangaron. In Hamburg, when using a Laptop in public transport, you are still met with puzzled gazes and sometimes even snide remarks, mostly by folks who one minute ago were busy scuffing their thumbs on their mobile's knobby keys.
The bug was, as most often, caused by over-optimization combined with sloppiness: The color was a shared object (aliasing), and its alpha value was modified, although Color objects are intended to be immutable. More over, the alpha value is used as (the only) indication of a dying player. For the time being, I just fixed the first issue, but will care about the others later.
If you played the game before and still experience the bug after reloading the page, try to clear your browser cache.
Have fun!