Web development and debugging Mobile Safari

Recently I ran into an issue with several websites and their functionality, or lack thereof, on Mobile Safari in iOS 4.3.3 on the iPad.

Mobile Safari doesn’t give you much in the way of native debug tools.  There is a debug console, which will display, at least in theory, any CSS, HTML or Javascript errors.

The only problem is that it won’t actually display all HTML errors.  For instance the problem I ran into was an HTML tag mismatch between an opening H2 and a closing H3.  Mobile Safari on iOS 5.1 displayed the page as designed, however on iOS 4.3.3 the bad closing tag was omitted which meant that all the children of that H2 had the CSS style “hidden” applied to them due to a class assignment.

You would think that this might trigger an error code in the debug console, however no such error occurred, and using the Safari iOS 4.3.3 – iPad user agent in desktop Safari on Mac OS X did not exhibit the error.

In searching for a tool to assist with debugging this problem natively on the iPad I ran across a great bookmarklet by Mark Perkins, called Snoopy.

This bookmarklet gives you all kinds of nifty information about the page you are looking at, including a view of the generated source.  Thanks to this tool I was able to find out exactly what was breaking the display on the iPad.

The missing Photoshop window and Mac OS X Lion

AMD Intel Graphics SwitchingOne of the touted features of the unibody design MacBook Pro line was the introduction of two different graphics processing units [1].  Initially they shared two Nvidia GeForce chipsets. Beginning with the Core i5 and Core i7 models, this was changed to use an Intel HD Graphics chipset and either an Nvidia chipset or an AMD chipset (depending on the model and year of introduction).

This was put forth as a great power savings feature, but as many users have seen it has had unintended consequences. [2, 3, 4]

I have had no real issues involving this until I fired up Photoshop CS5 last night and found that the canvas window was missing! Now to be fair this doesn’t appear to be a problem on Snow Leopard, but nonetheless it was passing strange.  After some diligent searching, I discovered that the solution appears to be turning off the automatic graphics switching and rebooting the laptop. (Hint: it’s in the Energy Saver system preference pane)

After doing this all was once again well with Photoshop.  So if you encounter some odd graphics issues with your unibody MacBook Pro and Lion, try it and see if it helps.

References

  1. MacBook Pro: About automatic graphics switching and OpenGL applications
  2. MacBook Pro Graphics Switching Issues
  3. Macbook Pro auto graphic switching issues!
  4. 15” Macbook pro graphic card swicthing problems

Changing the default editor on Dreamhost

While setting up the cronjob for auto archiving data on my Piwik installation, I found that the default editor for Dreamhost shell accounts is set to use joe (Joe’s Own Editor). While this is a nice editor for many users, it is not as familiar to me as using vim, the opensource vi clone.

Combing through the Dreamhost wiki, I found the line in the crontab wiki article talking about exporting the editor setting by adding an entry in the .bashrc file in the root of your account.  This information may have been accurate at one point, but now the shell accounts are configured to use .bashrc for the non-interactive logins and to use .bash_profile for the interactive logins.

So to update you editor on your shell account you need to add the following line to the .bash_profile file:

export editor="/usr/bin/vim"

or

export editor="/usr/bin/vi"

If you prefer to use emacs, you can change the line to be:

export editor="/usr/bin/emacs"

Resurrecting G3 iBook with Linux

At work we are in the process of sorting through some old books, documents and equipment in the run-up to moving into a new building.

During this process I ran across an old Mac iBook.  The model I found was a stock configuration iBook G3/800, model number A1005.  After turning it on I discovered that it was running Mac OS X 10.2.8.  My manager suggested that we just discard it since it was not upgradeable to the latest OS level and since the hardware specs were so low.  Given my penchant for playing with old, sometimes admittedly obsolete hardware, I decided to see what I could do to resurrect the little guy with Linux.

After investigating the various options available, I settled on Linux MintPPC.  This particular distribution is a port of the Linux Mint LXDE project to Debian/PPC.  The reasons behind this choice were:

  1. Use of lightweight X11 window manager, which is important given the paucity of memory and hardware resources in the iBook
  2. This distro is based on the Linux Mint project and Debian/PPC Linux

Installation

The installation couldn’t be much easier.  I downloaded the latest Debian/PPC net install iso image, then started up the laptop from the CDROM.  At the boot prompt enter the following:

auto url=mintppc.org

After this it’s a simple matter of walking through the standard installation process for Debian then letting the network install complete on it’s own.  After approximately an hour, I had a fully functional Linux install working on the iBook!

Post-Install Niceties

Right Mouse Click

After the installation was completed and the laptop had rebooted I began a few post-installation configuration changes.  This model iBook didn’t have the multi-touch capabilities that Apple introduced in later models, so it was limited to left-button only operations unless you add in keyboard modifiers.  The default configuration for the left and middle button operation is to use the F11 and F12 keys to operate the buttons.  Since MintPPC includes the mouseemu daemon, I wanted to configure the system to use the Mac OS X configuration of control-click to operate the right mouse button since this was the mode I was used to.  Here’s how to accomplish that:

  1. Open the terminal and become root
  2. cd /etc/default
  3. vi mouseemu (you did backup the original right?)
  4. Add the following to the end of the file:
    RIGHT_CLICK="-right 29 272"
  5. Restart the mouseemu daemon:
    kill -HUP `cat /var/run/mouseemu.pid`
  6. Enjoy the new configuration!

Turn Off Login Ready Beep

By default the system is configured to beep when the system is ready for login.  Since I work in a cube farm, I wanted to observe better cube etiquette by disabling this.

  1. Open up the Login Window preferences: Menu -> Preferences -> Login Window
  2. Enter the admin password into the authentication dialog (this is root, not your sudo password!)
  3. Click on the Accessibility tab
  4. Uncheck the box next to Login screen ready

Openbox Configuration Tweaks

There are a number of configuration tweaks that can be made to the default Openbox setup to improve rendering performance on machines at the low-end of the spectrum.  Here are a few that I have made.

  1. Menu -> Preferences -> Openbox Configuration Manager
  2. Appearance
    1. Uncheck Animate iconify and restore
  3. Move & Resize
    1. Uncheck Update the window contents while resizing
  4. Desktops (very subjective change with negligible performance benefit)
    1. Set Number of desktops to 2
I am still working on the final configuration to fit the hardware footprint on the iBook G3, so there will be more updates along these lines soon.

Network port troubleshooting with Perl

Recently I had a need to test network communication between two different services over a specific port for a clustered application.  Since I didn’t want to have to initiate an application failover just to test the network communication, I decided to use a simple Perl script to listen for inbound communication on the cluster node being tested from the development environment.

What the code does is to open a specific port for listening.  I used the basic telnet client to send traffic from the source machine (client) to the destination machine (server).

Here are the code listings for the script for both Solaris 10 and AIX 6.1.

Solaris 10

#!/usr/bin/perl -w
 
use strict;
use warnings;
use IO::Socket;
 
# Local host bind address (hostname/ipaddr)
my $LOCALADDR = 10.0.0.1
# Local host bind port
my $PORT = 10240;
 
my $sock = new IO::Socket::INET (
    LocalHost => $LOCALADDR,
    LocalPort => $PORT,
    Proto => 'tcp',
    Listen => 1,
    Reuse => 1,
);
 
die "Could not create socket: $!\n" unless $sock;
 
my $new_sock = $sock->accept();
while(<$new_sock>) {
    print $_;
}
 
close($sock);

AIX 6.1

#!/usr/bin/perl -w
 
use strict;
use warnings;
 
use IO::Socket;
use Net::hostent;              # for OO version of gethostbyaddr
 
# Local host bind address (hostname/ipaddr)
my $LOCALADDR = 10.0.0.1
# Local host bind port
my $PORT = 10240;
 
my $server = IO::Socket::INET->new(
    Proto => 'tcp',
    LocalHost => $LOCALADDR,
    LocalPort => $PORT,
    Listen => 1,
    Reuse => 1 )
or die "can't setup server";
 
print "SERVER Waiting for client connection on port $PORT\n";
 
my $new_sock = $server->accept();
while(<$new_sock>) {
    print $_;
}
 
close($server);