Enabling orientation change uncovers latent resource leaks.
As noted inn this comment in merge request !310, enabling landscape mode leads to crashes. One such crash that shows up rather quickly is attached landscape-crash.log.
This portion, in particular, points to leaking BroadcastReceivers generated by Picasso:
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:747)
at com.squareup.picasso.Dispatcher$NetworkBroadcastReceiver.register(Dispatcher.java:548)
at com.squareup.picasso.Dispatcher.<init>(Dispatcher.java:120)
at com.squareup.picasso.Picasso$Builder.build(Picasso.java:862)
at audio.funkwhale.ffa.utils.CoverArt$Companion.buildPicasso(CoverArt.kt:217)
at audio.funkwhale.ffa.utils.CoverArt$Companion.withContext(CoverArt.kt:257)
at audio.funkwhale.ffa.adapters.FavoritesAdapter.onBindViewHolder(FavoritesAdapter.kt:72)
at audio.funkwhale.ffa.adapters.FavoritesAdapter.onBindViewHolder(FavoritesAdapter.kt:27)
A closer look suggests not just a leak, but that the app unnecessarily create a new Picasso object for each CoverArt reference. There a few optimizations that can help address this leak.
Further testing with the AndroidStudio profiler indicates significant memory leaks as configuration changes (portrait/landscape switching) destroy and recreate instances of MainActivity. The destroyed objects cannot be garbage collected because multiple adapters, repositories, and other miscellaneous objects hold a static reference to the MainActivity context.
Merge request !310 (closed) is an attractive argument for enabling landscape mode. This issue is meant to track progress in addressing the resource leaks that prevent us from doing so.