My app was printing lots of logs - about 5k in 2-3 seconds, and once every few runs not all logs were printed.
I was using Log.d to print them, which seems to be optimised out under some conditions.
Replacing Log.d with Log.wtf, which is not optimised out, solved my issue.