Skip to content

The same button, two different OS rules

Abdul-Qudus Rufai 2 min read

Span’s design has the same screens on iOS and Android for camera access and AR support. Building both showed that the same button can need different code, because each operating system has its own rules underneath.

“Not now” led to a dead end on iOS

The design’s camera screen has a “Not now” option. If you skip, it later shows “Open Settings”, so you can turn the camera on there.

On iOS, that would have been a dead end. iOS only lists an app’s camera switch in Settings after the app has asked for permission at least once. Tapping “Not now” skipped the system prompt, so the app had never asked, and Settings would have had nothing to turn on.

So until the app has asked, the button says “Allow camera” and shows the system prompt. “Open Settings” only appears after a real refusal. This changes the design’s wording, but the design’s version could not work.

On Android, “Open app settings” works straight away, because Android always lists the camera permission under App info. Same button in the design, different rule behind it.

ARCore is an app, not part of Android

ARKit is part of iOS. Every iPhone that can run it already has it. ARCore is different. It is an app from Google, Google Play Services for AR, that may not be installed, and only certified phones can run it at all. My own Android phone cannot.

That changes the app in three ways:

  • The manifest marks ARCore as optional, so a phone without it can still install Span and use the level, quotes and projects
  • Span checks whether ARCore is available, and shows an install dialog when it can be installed but is not
  • Returning from Google’s install screen is how the app learns ARCore is now there, so it checks again every time it comes back

Bugs found by reading, before a phone

The emulator never runs this code, so no test could catch problems in it. Reading it found three before it reached a phone:

  • ARCore’s first answer is often “still checking”, and the app read that as “not installed”. On a phone that already had ARCore, tapping Install opened nothing and the app never checked again. It now waits out the checking answer and checks again after the button
  • Creating an ARCore session throws an exception if ARCore is missing or broken, and nothing caught it. It now shows the tracking lost state instead of crashing
  • The screen size was only passed to ARCore when the camera surface appeared, and the session might not exist yet, which could leave a black camera. The size is now applied on the first frame where both exist

These fixes still have not run on a real ARCore phone. That is the next thing to test on Android.

Read the Span case study