The Case of the Sleeping MacBook

Sitting on the late night subway train home in Tokyo, I thought I’d try to finish off some code I’d been writing that day. I wouldn’t usually pull out my MacBook on the train, especially a busy Japanese train, but I’d snagged a seat and the problem was still swimming in my head and I thought I could knock it over on the 45 minute ride home.

But about 15 minutes into the trip, my screen suddenly turned black. Not like a freak-out, something went terribly wrong cut-to-black, but a gentle, Apple-like slow fade to black. The kind of fade to black you get when you actually ask your computer to go to sleep. That’s odd, I thought, that’s never happened before. My laptop wasn’t plugged into anything nor had I bumped the power button. I was simply typing away in a terminal when it happened.

It was around 10:30pm, and many of the passengers were lightly sleeping. The train was quiet and humming along quickly and smoothly. A drunk businessman fell into another man and apologised in English.

I pressed a few keys in an attempt to wake it up, and sure enough after a few moments the screen returned as if nothing had ever happened.

Nothing to see here, move along

I continued coding, chalking it up to a glitch in the matrix. A few minutes later though, it happened again. This time I took my hands off the keyboard. It woke itself up about 5 to 10 seconds later. Strange. I continued coding. It happened again. I kept my hands off. It was happening without any intervention, and with uncanny regularity, a few minutes apart each time.

Tokyo residents are incredibly talented at squeezing in some shuteye on the trains, even while standing. Often somebody will fall asleep, fall into the wall, wake up, fall asleep again and repeat over and over until - through some kind of sixth sense - they suddenly awaken just as the doors open at their stop. Maybe this culture was wearing off on my laptop. After all, my smartphone changes its personality to fit in when in Japan. Putting in a local SIM card disables the camera’s “shutter sound” setting, forcing it to always make a shutter sound, even when on silent, just like every single mobile phone in Japan.

This strange sleeping behaviour only started happening after I changed seats. About 15 minutes into the train ride the coveted end seat opened up, which has the benefit of being next to a dividing wall. This means you only have to sit beside one person instead of two. These seats are precious, they are always the first to be occupied. Was my MacBook aware that the end seat was significantly more suitable for sleeping, since you can lean your head against the dividing wall instead of falling asleep on a stranger’s shoulder? Don’t be silly, a MacBook doesn’t have the capability to feel embarrassed. It was late, my head was still in programming-mode, and I thought I was going a bit mad.

Then it hit me. A week earlier, I’d noticed the compass indicator on my Android would go haywire on Tokyo’s trains. The magnetic field from the train’s electric motors must be doing something to my MacBook. But surely something more sinister must be happening with a magnetic field strong enough to put my MacBook to sleep… There are no magnetic disks in MacBooks anymore, and I wasn’t carrying any floppy disks so at least that wasn’t a concern.

What does the MacBook possibly have that would respond to a magnetic field?

The lid sensor.

mind blown

The MacBook uses a Hall effect sensor to detect the presence of a magnetic field. The magnets in the lid cause a change in the magnetic field, which the Hall effect sensor picks up, thereby putting the Mac to sleep. But so do the electric motors in Tokyo trains.

Since I still had a few stops to the destination, I tested this theory. Sure enough, just as the train started accelerating out of the station, my Mac would fall asleep. It then stayed asleep until the driver lightened his foot on the gas pedal and the train started coasting along.

tldr: Good luck using a MacBook on the Tokyo subway.