A phone app has a camera mode. The user points the phone at an object, takes a picture, and the server says what it is. To save a tap, the mode learned to capture by itself: when the view changes and then holds still, it takes the picture.

That trigger went out to users without the check that asks “is this the thing?”. Every scene change became a paid request, and many of them became an error card the user never asked for. A trigger and its gate are one feature. Shipped apart, the trigger alone does the damage.

Key facts

  • One user’s 24-second screen recording: 4 captures, 0 taps.
  • In the 7 days after the update: 7,200 automatic captures from 119 users.
  • 2,001 of them (28%) were not the target at all.
  • 606 of the 3,611 matches were the same item for the same user within 60 seconds.
  • 67 of the 119 users had at least one minute with 5 or more automatic captures.

How the trigger decides

The trigger works on a tiny fingerprint of the camera view: a perceptual hash. The phone shrinks a frame to 8x8 brightness values and turns them into 64 bits. Two views that look alike give hashes that differ in few bits.

The trigger fires when all of these are true:

  • 10 or more of the 64 bits differ from the last captured view.
  • The view has held still for 400 ms.
  • The view has some contrast.
  • 2.5 seconds have passed since the last capture (a cooldown).

Read the list again. Nothing in it asks whether the object is in the view. A desk changes the hash and holds still. So does a keyboard, or a hand. Each one fires the trigger as well as the object does.

The gate came ten days later

The missing piece was written about ten days after the trigger. It had two parts: a check on the phone that asks “is the object in the picture?”, and a rule that a failed automatic capture shows nothing. Both were in the main branch.

The update that users got was published by hand, outside the normal release pipeline. It was cut from a commit between the two: trigger in, gate not yet. The pipeline’s own publish step had been skipping, so nobody expected an update to be out at all. A green run that published nothing is one half of this story. This is the other half: what a hand-made release then carried.

How it was found

No alert found it. One user’s 24-second screen recording did. In it, the app took 4 captures and the user made 0 taps. 3 of the captures ended in a “Not found” card: the desk, or the object while it was still moving. The fourth added a duplicate card for an object the app had already found.

Before the update there were 0 automatic captures. The first one came 27 minutes after the update was published.

What 7 days showed

Over the 7 days after the update, there were 7,200 automatic captures from 119 users. For scale, taps in the same days gave 4,425 captures from 169 users. Fewer people used the automatic mode, and it still made more requests.

Here is how the automatic captures ended:

OutcomeCapturesShare
Matched3,61150%
Real object, no match1,58822%
No object in the picture1,21817%
Not this kind of item78311%
Total7,200100%

The last two rows are the trigger firing on the wrong thing: 2,001 captures, 28%, were not the target at all. Those are the captures the gate is meant to stop on the phone.

Even the matches were not all useful. 606 of the 3,611 were the same item for the same user within 60 seconds: the view moved away, the same item came back into it, and the trigger fired again. And 67 of the 119 users had at least one minute with 5 or more automatic captures.

What each miss cost

Each capture that reached the server ran two paid model calls in parallel and stored the photo. A capture of a desk cost the same as a capture of the object. The money was not measured, so this article gives no figure; an estimate is not a measurement.

Each miss also cost the user. They got a “Not found” card for something they never asked about, and duplicates in their history. The app looked broken in a mode built to save them effort.

What we do not know yet

When this was written, the gate was in the main branch but not yet on users’ phones. So there is no “after” number here. We do not know yet how much of the 28% the gate will stop, or how many repeats will remain.

Check your own

  • Flag every automatic request. For anything that fires by itself (auto-capture, auto-save, auto-retry, auto-send), log a flag “automatic” on every request, from day one. Without it, the 28% cannot be counted.
  • Watch two numbers. On automatic actions, track the share that was not the target and the share that repeats the same result within a minute.
  • Put a cheap check in front of the expensive call. Ask on the device whether the object is there at all. Ship that check in the same change as the trigger, behind the same switch.
  • Make a failed automatic action silent. The user did not ask, so there is nothing to report to them. Show errors only for what they tapped.
  • Do not let the same result fire twice. Remember the last result, and require a real change of scene, not only movement and stillness.
  • Diff a hand release before you publish it. It ships whatever commit it was cut from. List what the main branch has that the cut does not. A gate written later is exactly what goes missing.

Shipping together is not always enough either; a guard and its key can ship together and still lock people out. But a gate shipped after its trigger never had a chance.

A sketch of the trigger with the gate in it, with made-up names:

// Fire only on a real change
// that looks like the target.
function shouldCapture(f, s) {
  return changedBits(f, s.last) >= 10
    && stillFor(f) >= 400
    && now() - s.lastAt >= 2500
    && looksLikeTarget(f);
}

async function autoCapture(f, s) {
  const r = await identify(f);
  // An automatic miss shows nothing.
  if (!r.found) return;
  // Same result again: stay quiet.
  if (r.id === s.lastId) return;
  s.lastId = r.id;
  show(r);
}

Common questions

Why not just raise the change threshold?

A higher threshold fires less often, but any big enough scene change still fires it. A desk is a big change. Only a check for the object answers “is this the thing?”.

Why make automatic misses silent?

The user did not ask for the capture, so a “Not found” card is noise they cannot act on. Show errors only for what they tapped.

Melta is free; get it on the App Store or Google Play.