* HTML 5 and sessionStorage

Posted on February 19th, 2010 by Dave Johnson. Filed under JavaScript, quirks.


We came across a strange bug today that was being caused by our recent addition of sessionStorage to our application.

The Mozilla Developer Center says this about sessionStorage:

This is a global object (sessionStorage) that maintains a storage area that’s available for the duration of the page session. A page session lasts for as long as the browser is open and survives over page reloads and restores. Opening a page in a new tab or window will cause a new session to be initiated.

Emphasis mine.

What we found was that of the three different browsers that currently “support” sessionStorage, there are three different implementations. Go figure.

I looked at a few different ways of opening new windows or tabs and those included anchor tags with target values of “” and “_blank”, window.open() JavaScript calls with different targets, and context menu open in new window or tab.

Internet Explorer 8 is furthest from the spec, as one might expect. No matter how you opened a new window from the page, the sessionStorage is preserved in the new window.

Firefox is only slightly better in that it does not preserve the sessionStorage in new windows when the new window is created by choosing open in new window / tab from the context menu on an anchor.

Safari is more or less like Firefox except that it does not preserve the sessionStorage when the target on an anchor is “_blank”.

In short, if you are expecting that sessionStorage is tied to a single browser window then think again.

Tags: , .



* Work

Posted on January 11th, 2010 by Dave Johnson. Filed under phonegap.


Crap it has been busy at work the past few months!

More to come soon though since I am working on a few small JavaScript libraries and two services that I will be releasing soon!

There has of course also been a tonne of amazing work being done on PhoneGap (tests, Palm, Nokia, simulator) - though not by me so much :)

Check out the latest at GitHub http://github.com/phonegap

Tags: , , .



* Managers and Technical Debt

Posted on September 2nd, 2009 by Dave Johnson. Filed under Business.


Managers love technical debt. It helps them to make it seem like they are doing a better job than they are. They can do this in a few ways.

First, by skipping tests and taking on other types of technical debt during development they come slightly closer to meeting tight timelines and releasing software that is not as good as it could have been, but good enough.

Second, when there are bugs found in the software the manager can blame the developers who were previously told to omit things like tests in an effort to get the software out sooner. Not only do the developers take the blame, but they are also forced to fix the bugs, often by working long hours outside of regular business.

The end result is that the software is closer to the quality it should have been in the first place, and the developers have done it in record time because they had to work evenings and weekends. And the manager, has not only released the software on time but he has also taken the credit for the heroic bug fixing effort.

That leaves the developers paying off the technical debt and looking for a new job where, hopefully, it won’t happen again.

Tags: , , .



* Passenger on Rails Playground

Posted on August 29th, 2009 by Dave Johnson. Filed under Uncategorized.


I finally setup Passenger (mod_rails) on my Rails Playground server the other day so that I can quit worrying about Mongrel and it is super easy. The main problem that I found was that I had a spelling mistake in my httpd.conf file in the PassengerRuby config line. The error that this produced in the Apache error_log file seemed to be referring to starting the spawn server.

Could not start the spawn server: /usr/local/lib/ruby: Permission denied (13)

So I spent a long time trying to find info about Passenger spawn server settings, but the problem in the end was that the path shown in the error did not exist - it should have been pointing to bin obviously :S

The other part of using passenger is the slightly different Capistrano recipe. With Passenger there is no spinner task and you need to put in an empty restart task. Here is my recipe:

########################
# Application
########################

set :application, “example.com”
set :deploy_to, “/var/rails/#{application}”

########################
# Settings
########################

default_run_options[:pty] = true
ssh_options[:forward_agent] = false
set :runner, “user”

########################
# Servers
########################

set :user, “user”
set :domain, “example.com”
server domain, :app, :web
role :db, domain, :primary => true

########################
# Subversion
########################

set :repository, “http://svn.example.com/trunk/server”
set :scm_username, “user”
set :scm_password, “password”

########################
# Passenger
########################

namespace :passenger do
desc “Restart Application”
task :restart do
run “chown -R apache:apache #{current_path}”
run “touch #{current_path}/tmp/restart.txt”
end
end

after :deploy, “passenger:restart”

deploy.task :start do
# nothing
end

The other thing that I found I had to do was the chown call since Passenger runs the Rails app with the same user as is running Apache, in this case the apache user and apache group.

Now on to try out Cassandra.

.



* Long Live PhoneGap for BlackBerry

Posted on July 30th, 2009 by Dave Johnson. Filed under phonegap.


There have been some new developments in the PhoneGap on BlackBerry breathing new life into the project! It all boils down to the fact that in RIM OS >= 4.6 there is a browser rendering option that you can set to make the browser render using the modern rendering engine rather than the archaic one from OS 4.2.

It look something like this:

_renderingSession.getRenderingOptions().setProperty(
  RenderingOptions.CORE_OPTIONS_GUID, 17000, true);

After much trial and error it was found that the BrowserContentManager did not support this rendering option (and RIM says it is completely unsupported / experimental anyhow) yet the Field returned from BrowserContent.getDisplayableContent() does support it!

Long story short it looks like PhoneGap on RIM OS >= 4.6 is going to work really well.

Next up is looking at the new features in OS 5.0.

Tags: , , , .



* PhoneGap iPhone Approval

Posted on June 13th, 2009 by Dave Johnson. Filed under mobile, phonegap.


The guys over at Rhomobile posted about IPhone App Store rejection issues the other day - I can only assume due to the recent problems that some users of PhoneGap have been having. Rhomobile and PhoneGap are similar in that they are frameworks that enable developers to build native mobile apps in a language they are familiar with, Ruby and JavaScript respectively.

I think that they are pretty much spot on in terms of their interpretation of the App Store rule 3.2.2 that states:

An Application may not itself install or launch other executable code by any means, including without limitation through the use of a plug-in architecture, calling other frameworks, other APIs or otherwise. No interpreted code may be downloaded and used in an Application except for code that is interpreted and run by Appleā€™s Published APIs and built-in interpreter(s).

The two key points in this App Store rule are where it says an app “may not itself install or launch other executable code by any means” and this is exactly what users of PhoneGap are doing if their apps are downloading JavaScript over the network rather than including it in the application www folder. By downloading JavaScript over the network at runtime the application is downloading and running interpreted code that Apple has not control over during their app approval process.

So if any of you PhoneGap developers are worried about Apple rejecting your app just make sure that you don’t download any JavaScript at runtime and instead include it in the application. Having said that, also make sure that you apps don’t look like you just took a shit and emailed it to Apple :)

That is just my thoughts on the issue, whether or not that is the *real* reason that Apple is rejecting PhoneGap apps we may never know but that is certainly one reason that they would do it I think. It could just be because they feel like it…

Tags: , , , .



* Where 2.0 Slides

Posted on June 7th, 2009 by Dave Johnson. Filed under Conference, mobile.


Here are my slides from my workshop at the recent O’Reilly Where 2.0 conference down in San Jose.

Where 2.0
View more PDF documents from davejohnson.

Tags: , , , , .



* Where 2.0 Workshop

Posted on May 17th, 2009 by Dave Johnson. Filed under Conference, mobile.


I am going to be running a workshop down at the O’Reilly Where 2.0 conference on Tuesday called Giving Your Mobile Apps a Sense of Place.

I am going to cover Geo related features and issues of IPhone 2.2.1, Android 1.5 (aka Cupcake), RIM OS 4.7, and, most importantly, PhoneGap. I will be sure to post the slides once I am done them as well as put all the sample projects up on my GitHub.

If you are in San Jose Monday night then you will probably find me in the bar, whether I am done my slides or not!

Tags: , , , , , .



* Windows Compilation Problems

Posted on May 5th, 2009 by Dave Johnson. Filed under Uncategorized.


If you are trying to use midl.exe but have not before or do not have Visual Studio installed, you may come across a few different errors.

One such error that I had was the following:

“command line error MIDL1001 : cannot open input file oaidl.idl”

So I figured out that I had to get the Windows Platform SDK installed but had a hard time finding it. There is a helpful page on MSDN I found that helps you to choose the right SDK. The link never came up in my search results for some reason and I was only able to find it linked from the Windows SDK blog.

I figured that I would just add that to the PATH environment variable as you may expect to be the case but alas it was not. After a long while of trial and error (mostly error really) I found that you can specify certain paths to be included manually as a command line switch http://msdn.microsoft.com/en-us/library/aa367328(VS.85).aspx

Tags: , .



* JavaScript Pub Sub

Posted on April 28th, 2009 by Dave Johnson. Filed under JavaScript, Uncategorized.


I was talking to someone the other day about the observer pattern in JavaScript and I was reminded about this JavaScript method that is part of Complete UI.

nitobi.Event.prototype.subscribeOnce = function(method, context) {
  var guid = null;
  var _this = this;
  var func1 = function() {
    method.apply(context || null, arguments);
    _this.unSubscribe(guid);
  }
  guid = this.subscribe(func1);
  return guid;
}

subscribeOnce is a special sort of event subscription that rather than being being executed every time the event fires, the handler function is only executed once and then automatically unsubscribed from the event. It is obviously most useful for initialization stuff in JavaScript. There is some more info on JavaScript pub sub over on Ajaxian too.

Tags: , , , .