Skip to content

Underruns when new ad is loaded by Admob: Affinity fixes it #2208

@peterdk

Description

@peterdk

I have a heavily used app (Mini Piano Lite) that is using Oboe for a long time already.
Recently I have improved my analytics setup and am also reporting underruns per session. This is quite insightful, cause I have around 14% of my users experiencing 1+ underruns and 5% 3+ underruns. I did a lot of optimization, like removing mutexes from the audiopath, lots of profiling with Perfetto, and generally my audio pipeline is quite optimized throughout the years. However, still the worrisome 5% 3+ underruns remain.

I also collect device models, and bought a few (older) devices that had the most underrun sessions happening and relatively the most underruns per session. (Galaxy Tab S6 Lite, Galaxy A50, Galaxy A51, but also Pixel 8(!)).
So time to profile a bit more with Perfetto, since the underruns happened very frequently and were consistently reproducible. After lots of experimenting it turned out that the Admob banner that is always visible and refreshes every 1 minute is the direct cause of the stuttering/underruns. Even when no audio plays (so no load, only a zero filled memset buffer) on ad change I get 10 underruns. Quite frustrating.

So I was planning to file a bug to get some help from you guys. Cause all ad stuff is optimized, using only Main thread when required, and all Google's recommendations and background thread loading settings applied.
But I came across a Oboe Github Discussions thread about underruns and there the example datacallback was shared with ThreadAffinity setup code. I tried it, and wow.... all my issues are gone!

So I think Admob causes some thread rescheduling / core moving when loading ads (on some devices), and setting Thread Affinity fixes that completely.

Ok, long story, but the thing is, I never found this recommendation in any Oboe docs (and I read a lot of them through the years). It would be really great to add somewhere a section on performance issues, and talk there a bit about this thread affinity. Maybe even consider this making a option for the builder and handling this Thread Affinity stuff in Oboe itself, and not rely on the callback code of each user. I can't be the only one using Oboe in a app with Admob.

Anyway, really looking forward to the analytics when I release this, but it seems a real gamechanger!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions