Friday, November 15, 2013

requestAnimationFrame will not fire on Mobile Safari if you are already doing too much work in a touch handler

I've lately been writing a whole bunch of front-end stuff for iOS at Brightside. One of the recurring themes is responding smoothly to touch input, with appropriate incremental rendering of the page. At one point I tried to use requestAnimationFrame to offload some of the re-rendering work from a touch handler (that was already doing some work) but that totally didn't work - the frames were not firing for long periods of time.

I've put together a simple demo to show the effect at The gist is that the touchmove handler is using (by default) 100ms for some work and then setting a timer. The demo uses both setTimeout with a wait of 0 and (request|webkitRequest)AnimationFrame and shows how long it takes for the request to fire. The animation frames pretty much don't come at all as long as you keep moving your finger.

This doesn't happen with mouse events on the desktop in either Chrome or Safari.

Saturday, June 29, 2013

Copying maps to TomTom XL Black - some kind of a solution

TL;DR: use Windows XP, in a VM if you like

I own a TomTom XL navigator. It typically gets used once a year when we make our annual pilgrimage to the West Country. Every year I buy the newest map and every year I have trouble getting it on the device - the copying is very, very slow. I'm not the only one either. I thought it was due to using OS-X, so I thought I'd try some alternatives. Below is the list of results:

  • OS-X 10.7, mbp: didn't complete in an amount of time I was willing to wait. Could abort in TomTom Home and eject. Error message: kernel: USBF: 409117.102 AppleUSBEHCI[0xffffff8012585000]::Found a transaction past the completion deadline on bus 0xfd, timing out! (Addr: 5, EP: 1) in Console.
  • Windows Server 2008 R2, desktop: didn't complete in an amount of time I was willing to wait, hung Explorer windows. Could not (always) close TomTom Home, could not always cleanly reboot. Error message: hundreds of Event Id 51. Description: An error was detected on device \Device\Harddisk1\DR1 during a paging operation. in Event log.
  • Linux (Ubuntu 12.04), desktop (same machine as for Win2008R2), using a manual copy of files or a dd of a disk image: seemed to hang permanently, unkillable process. Error message: kernel: usb XX-XX: reset high speed USB device using uhci_hcd and address XX in dmesg.
  • Windows XP (mbp, in a Parallels VM): success!. Took roughly 45 minutes. Some Event Id 51s in event log, but only some.

I think the USB controller on the XL is just not very good, and modern OS's have more trouble with it. People talk on the intertubes about letting it run for three days, maybe that would have worked on OS-X.

Things that I tried that didn't help:

  • OS-X, Linux: Stopping the copying when the first error appears, ejecting and restarting - it would still get stuck on the single big file.
  • Linux: Setting max_sectors in /sys/block/sdX/device
  • Repartitioning or reformatting the device, including moving the start of the partition
  • Running TomTom's 'clear flash' tool
  • Dropping from high-speed to full-speed in the BIOS (using both Windows 2008 and Linux). (I'm not sure this actually affects how the bus works under OS control.)
  • Using a powered USB hub instead of the computer's ports

BTW, if you are a Windows user, you should be able to get a free XP VM from Microsoft. I haven't tried that a) with TomTom or b) at all.

Monday, June 10, 2013

Elämme kuukauden vuoden 1971 kulutustasolla

Teimme Niinan kanssa kokeen siitä, mitä elämä olisi kolmanneksen elintasolla. Tulokset julkaistaan osoitteessa

Thursday, March 28, 2013

Monday, February 11, 2013

Problems with code review are symptoms of problems in your team or engineering

The only process Google forces on teams is code review. Nobody is exempt, though teams may have varying strictness in their review.

We do code review at ZenRobotics too. It mostly works, but maybe not extremely well.

I see code review (in general, not just at ZenRobotics) not working as a symptom: it indicates a problem elsewhere. I've seen at least the following underlying issues getting reflected in code review:

  1. Lack of tests: if you don't have good tests, you are very reluctant to make changes in code that you think works. This means you resist the changes that others propose, since you fear you'll break your code.
  2. Code that is difficult to understand (including convoluted designs or architecture): if the code is hard to understand, people will either require a lot of comments (which may be seen as counterproductive), extensive rewriting (without specific guidance on how to re-write since they didn't understand what your purpose was), or less-than-useful reviews that just look at the surface.
  3. Style guide violations: both reviewers and people who wrote the code under review quickly get annoyed at stylistic comments. At Google the idea was that  you internalize the style guide under the first couple of weeks of using a language and after that you don't need reminding. Code in review with style violations may also mean you lack tool support to make style checks easy. It could also mean that your team-mates don't actually agree on your coding style, which makes it pretty useless.
  4. Not knowing the components others are working on / not having time to understand them when reviewing: if you don't have at least one other member on your team who understands the stuff you work on, you have a very low bus factor - could even mean people are starting to create fiefdoms, or that code reuse is very low.
Now fixing issue no 1 (Lack of tests) or 3 (Style guide violations) doesn't make reviews free. However a lot of the cost of reviews is in fixing 2 and 4 - which you want to fix anyway. Especially, code reviews are great for implementing shared ownership and knowledge transfer.

(This doesn't mean I'm certain that code reviews suit every situation. What if you want to quickly iterate on your MVP? What if you want to quickly prototype an idea or a design? Anybody else have an idea?)