nvx/apertureAll write-ups
No. 06ENGINEERING · 4 min

My off switch didn't switch anything off

20 weeks as an Android dev on the Monash Study App (90,000+ students a day). The off switch that still made the request, a date past 2038 that rewrote itself to 1909, and the crash that only happened with two links.

By Cyber security, Monash University

I turned a feature off and the app kept calling the server anyway. It was one of three bugs that taught me more than the rest of my placement combined. From July to November 2026 I was an Android dev on the Monash Study App team (eSolutions, the uni's central IT), on a 20-week placement.

More than 90,000 students open the app every day during semester, so every bug has an audience.

Students a day in semester
90,000+
PRs to move News to Compose
11
Lines of dead XML deleted in one go
1,565

Bug 1: the off switch that didn't switch anything off

The team wanted to kill a feature from a server, with no app update, for when a backend is having a bad day. The app already used Firebase Remote Config, so I added switches for News and My results.

The two rules for the switches
RuleWhy
A missing value means onA config hiccup can't hide a working feature
The switch is read when you open the screen, never liveNothing vanishes under your thumb
Turning News off: gating the UI, then gating the flow4 steps
  1. 01scr to feed: Subscribe. The screen is being built, and it subscribes to the feed while it does. Feed: subscribed.
  2. 02feed to net: Request. Paging starts loading the second something subscribes, so the network request goes out. Network: request sent.
  3. 03The switch is off, so the screen shows "switched off". The request has already gone. News screen: shows "switched off".
  4. 04sw to feed: Off. The fix is at the flow. A cold flow does nothing until collected, so with the switch off, don't collect it, and hand the list an empty page so everything downstream still works. Network: no request; News screen: empty page; Feed: not collected.
My results, the twin of that bug

Checking the switch before the fetching state fixed it.

Bug 2: a date in 2046 that came back as 1909

Where a signed 32-bit int stops
  1. 119 Jan 20382,147,483,647 secondsThe last second a signed 32-bit int can hold
  2. 219 Jan 20462,400,000,000 secondsMade-up value
  3. Fits in a signed 32-bit int0 seconds to 2,147,483,647 seconds
  4. Too big for it2,147,483,648 seconds to 4,294,967,295 seconds
Seconds since 1 January 1970. The 2046 value is the made-up one from the code below.
Two paths reading the same model
GradesTimetable
How the timestamp was readAs an Int fieldThrough a helper that did toInt()
What happenedGson refused it, and one bad field fails the whole responseIn Kotlin toInt() doesn't throw. It wraps
What the user sawA crashA date silently turned into 1909
FixWidened the field to LongSplit the helper into a Long one for timestamps and an Int one for small counts, labelled which is which
The maths, with a made-up value
1val seconds = 2_400_000_000L    // 19 Jan 2046
2val narrowed = seconds.toInt()  // -1_894_967_296
3// as a date: 14 Dec 1909
  1. 1L2Keeps the low 32 bits. No exception, no warning, just a different number.

So the screen that crashed was the lucky one. The timetable path never complained. I added tests right at the 32-bit edge.

Moving News to Compose, 11 shippable PRs6 stages
  1. 01

    Post cards

    Built and tested, unused

  2. 02

    Detail, then feed

    LazyColumn, stable keys, load-state rows

  3. 03

    Groups + channels

    Old toolbar bridged with nested-scroll interop

  4. 04

    Delete dead code

    28 files

  5. 05

    One Explore screen

    Logic into the ViewModel

  6. 06

    Collapsing header

    One clamped float

The collapsing header, my favourite bit4 steps
  1. 01One number, how collapsed the header is, clamped from 0 to its full height, drives everything. Collapse amount: 0 to full height.
  2. 02nsc to num: Collapse first. A NestedScrollConnection sees every scroll before the list. Scrolling down spends it collapsing the header first.
  3. 03nsc to num: Restore first. Scrolling up restores the header first. It is the same maths in both directions, so it can't get stuck half open.
  4. 04The list's scroll state is hoisted above the tab switch, so coming back to News puts you where you were. List: state kept across tabs.
Release testing 2.44.0, paraphrased4 lines
scroll news feed ... ok
open post with 1 link ... ok
scroll past post with 2+ links ... crash
painterResource: only vector or bitmap images, got a shape drawable1
  1. 1L4Posts with 2+ links draw a little bullet, an XML shape
From crash to patch4 stages
  1. 01

    Bullet is an XML shape

    Loaded through painterResource, which only takes vectors and bitmaps

  2. 02

    Can't convert it

    Its colour came from a theme attribute

  3. 03

    Draw the dot in Compose

    No file to load

  4. 04

    Patched the same day

Every test I'd written for that card used one link. The regression test uses two.

Also shipped

WhatDetail
Android 17Target SDK 36 to 37, ahead of Play's deadline
WebView headers for the in-app assistantreload() dropped the headers given to loadUrl (in my testing), so retry re-issues loadUrl instead
TestingRegression and product verification for 2.42.0 and 2.43.0, and 2.44.0 end to end
ReviewThe team's reviews and CI behind every change

The part that isn't Android

Requests to an upstream service the app relies onabout 40 million requests
  • 39%Errors for enrolled studentsAbout 15.5 million, 39%
  • 61%Everything else
About 40 million requests, and about 15.5 million of them errors for students who were enrolled.

I wrote a read-only Python tool to sample accounts at scale. The pattern wasn't about students at all: failures were a property of the course offering. If an offering failed, it failed for everyone in it. That points at caching per offering, so I proposed a fix aimed at that ~2-in-5 share.

Where the fix is today4 stages
  1. 01

    Agreed

    With the team that owns the service

  2. 02

    Built and tested

  3. 03

    Reviewed and approved

  4. 04

    Live in production

I found an auth weakness on the way, responsibly disclosed it, and it has since been fixed. The fix for the 404s has its own post: Why 39% of our API calls came back 404.

No comments yet

Comments are read before they appear.