DevOps by Default Blog

Radiophonia 1.3.2: Fire TV R8 Traps, OLED-Safe Artwork Clocks, Smarter Podcast Queues, and Desktop Efficiency


Radiophonia 1.3.1 and 1.3.2 focus on two fronts since v1.3.0: hardening platform behaviour where stores, desktops, and streams behave differently from dev machines, and adding three user-facing features built on the existing stack — a configurable full-screen artwork clock overlay with OLED burn-in protection, podcast Up Next reordering and multi-part series tools, and a redesigned Settings layout.

Radiophonia 1.3.2 architecture — podcast queues, living-room TV, and desktop efficiency flowing through the shared radio engine into the full-screen artwork clock

Amazon Fire TV IAP: How Missing R8 Rules Triggered an Infinite Play Billing Loop

The Problem

Our Fire TV submission failed Amazon Appstore review with an ugly symptom: pressing Upgrade to Premium spun on “Processing…” forever without opening Amazon’s purchase sheet. Debug builds didn’t reproduce it, which pointed straight at release minification — and the fallback behind it:

  1. R8 stripped Amazon Appstore SDK internals: android/app/proguard-rules.pro lacked keep rules for com.amazon.** and *Annotation*. In release APKs, R8 removed reflection metadata that the Amazon Appstore SDK needs to bind, causing Amazon IAP initialisation to fail cleanly enough to return false.
  2. Play Billing’s infinite reconnect loop on non-Play devices: When Amazon IAP returned false, StorePurchaseService fell back to in_app_purchase_android. On a Fire TV Stick with no Google Play Services, BillingClientManager.runWithClient retries BillingResponse.serviceDisconnected in an infinite backoff loop rather than surfacing unavailability — leaving the Flutter UI waiting for a result that never resolves.
  3. Bridge lifecycle and signed-out fulfillment gaps: The native MainActivity.kt Amazon IAP bridge also needed earlier listener registration in onCreate, explicit UI-thread callback marshalling (runOnUiThread), safe init retries after transient failures, and notifyFulfillment handling for signed-out purchases and canceled receipts.

The Solution

  • Added -keep class com.amazon.** { *; } and -keepattributes *Annotation* to android/app/proguard-rules.pro so release builds keep the Amazon Appstore SDK intact.
  • Made Play Billing instantiation lazy in StorePurchaseService and pinned STORE_CHANNEL=amazonAppstore builds (_forceAmazonIap) strictly to the Amazon channel — they never construct or query InAppPurchase.instance, even if Amazon SDK init returns an error.
  • Reworked the com.gibbsoft.radiophonia/amazon_iap bridge in MainActivity.kt to register PurchasingService.registerListener in onCreate, marshal every response callback to the Android UI thread, clear canceled states, call notifyFulfillment for signed-out local grants as well as server-validated ones, and allow clean re-initialisation retries.
  • Added regression coverage in test/services/store_purchase_service_test.dart exercising Amazon init timeout, fallback suppression, and canceled/fulfilled states.

The Lesson

Fallback logic across mutually exclusive store SDKs is dangerous: if SDK A fails in release mode (say, because of R8) and falls through to SDK B whose retry loop never terminates on that hardware, a recoverable init error turns into an infinite hang. Make store channel selection a build-time invariant, not a runtime fallback.

Full-Screen Artwork Clock and OLED Burn-In Protection

The Problem

Radiophonia runs full screen on living-room Google TV and Fire TV sets as well as bedside tablets and desktops, and listeners asked for a subtle clock on top of full-screen album artwork. Two constraints shaped the design: it must never leave static bright pixels parked on OLED panels, and it must not wake the widget tree once per second when seconds aren’t shown.

The Solution

Built a self-contained clock subsystem (ClockSettings, ClockSettingsScreen, and ArtworkClockOverlay):

  • Two faces, five typography styles: ArtworkClockOverlay renders either a custom-drawn _AnalogClockPainter or a formatted digital clock in Modern, Bold, Classic serif, Mono, or a geometric custom-drawn 7-segment LED painter (_SevenSegmentPainter). Options include System / 24-hour / 12-hour, optional seconds, optional flashing colon (:), four corner/centre positions, scaling up to 300%, and independent foreground/backdrop swatches and opacity sliders.
  • Boundary-aligned timer scheduling: _ArtworkClockOverlayState schedules a single-shot Timer aligned to the next exact second only when showSeconds || (style == digital && flashColon). Otherwise it schedules straight to the next minute boundary (:00), avoiding 59 needless rebuilds per minute.
  • Unified OLED burn-in drift (BurnInDrift): Rather than shifting only the clock, ArtworkClockOverlay.burnInOffsetFor computes a smooth Lissajous orbit (step = now.millisecondsSinceEpoch ~/ 120000, every two minutes) shared across every static overlay on full-screen artwork — the clock, the “i” song-notes button, and the purple playing meter.
  • Non-intrusive and device-local: ClockSettings is omitted from PreferencesRepository.syncableKeys so a living-room TV’s 250% corner clock never overwrites your phone; the overlay wraps itself in IgnorePointer so tapping anywhere still closes full-screen artwork; and it hides automatically while SongNotesOverlay is open. ClockSettingsScreen adapts live previews side-by-side on wide/TV screens and pinned at the top on mobile.

The Lesson

Burn-in mitigation on an ambient screen has to be a property of the whole overlay layer, not one widget — shifting the clock while leaving the "i" badge or playing meter anchored at fixed pixel coordinates solves half the problem.

Podcast Queues and Multi-Part Series: Reordering Without Breaking Sync

The Problem

Radiophonia’s podcast Up next queue previously sorted entries strictly by episode state timestamps, which meant you couldn’t drag episodes into your preferred listening order, defer an episode to the back of the queue (Play later), or reset an accidentally tapped episode back to unplayed. Worse, multi-part series that vary their titles slightly — say Part 1, Part Two, IV, or a differently-named finale — forced listeners to scroll blindly through long feeds to line up the rest of the story.

The Solution

  • Synced Up Next reordering without a sidecar table: Anchored explicit Up Next ordering timestamps in PodcastRepository so mobile/desktop drag handles (ReorderableListView cleanly integrated inside the outer scroll view), TV remote menu actions (Move up, Move down, Move to bottom), Play later (end of Up next), and Mark as unplayed persist reliably across restarts and sync through the existing episode-state sync model without inventing a fragile second priority list.
  • Automatic schema migration (feedFormat = 4): Bumped PodcastRepository.feedFormat to 4 so cached podcast feeds from earlier versions automatically re-parse once to populate <itunes:season> and <itunes:episode>. That unlocks Newest first / Oldest first sorting plus All / Unplayed / In progress and Season filter chips on every show page.
  • Series & chronological neighbour finder (podcast_series.dart + PodcastSeriesSheet): Find other parts detects series markers (Part 4, Pt. 4, Part Four, Roman numerals, 4/6, #4, or matching <itunes:season>), extracts the series stem, offers one-tap Queue in order / Queue unplayed buttons, and always displays the chronological neighbours published right before and after the episode so an irregularly titled episode right next to it is one click away.

The Lesson

Encoding user-reordered queue positions into monotonic timestamps on the existing synced entity avoids dual-source-of-truth merge conflicts when two devices sync offline changes.

Desktop Power Efficiency, Station Hygiene, and the Play Store Rollout Trap (v1.3.1)

Between v1.3.0 and v1.3.2, v1.3.1 shipped several infrastructure fixes worth calling out:

Platform-Aware Desktop Efficiency (EfficiencyModeService)

Desktop listeners often leave Radiophonia minimized for hours. Listening to WindowListener focus/minimize transitions and active playback/recording state, EfficiencyModeService transitions each desktop OS between normal, lowPowerAudio, and lowPowerIdle over a com.gibbsoft.radiophonia/efficiency_mode channel:

  • Windows (windows/runner/efficiency_mode.cpp): Uses SetProcessInformation(ProcessPowerThrottling) (EcoQoS) paired with BELOW_NORMAL_PRIORITY_CLASS while streaming/recording (protecting audio buffers from starvation) and IDLE_PRIORITY_CLASS (Task Manager green leaf) when paused or stopped.
  • macOS (macos/Runner/AppDelegate.swift): Holds ProcessInfo.processInfo.beginActivity(options: .userInitiatedAllowingIdleSystemSleep) only while streaming/recording in the background, releasing it when idle so macOS places the process straight into App Nap.
  • Linux (linux/runner/my_application.cc): Lowers process niceness (+5 audio / +10 idle) via setpriority only after checking RLIMIT_NICE permits restoring priority cleanly back to 0 on foregrounding.

Why Google Play’s API Told Us a Draft Was Live

Our version.json update check began offering v1.3.0 to Android Play users before Google Play had actually published it. The culprit was the Google Play Developer API’s tracks/production endpoint: it flips status to "completed" as soon as CI submits a 100% rollout — before Google Play human review approves and serves the APK. Switching scripts/store_monitor.py to parse the live public Play Store listing page directly — and adding an in-app InAppUpdate.checkForUpdate() gate on Play builds before showing a deferrable prompt — ensures regional or review lag can never trap users in an update loop.

Central Station Hygiene, Homepage Icons, ICY Encodings, and iOS DLNA

  • Unified eligibility (StationEligibilityService): Moved station filtering centrally onto StationCacheService (covering Discover, Browse, Search, Voice, CarPlay, and Android Auto): drops bundled assets/curated/blacklist.json entries everywhere except existing Favourites (“Unreachable”), hides stale stations (lastcheckoktime_iso8601 older than 7 days) from discovery, filters FLV and plain http:// streams on the HTTPS web build, and suppresses stations after 2 consecutive terminal start failures in device-local StationFailureMemory (7-day decay, cleared immediately on playback).
  • Direct homepage icon fallback (HomepageIconService): For stations with missing, broken, or .ico favicons in RadioBrowser (such as 8080s and BFBS), StationAvatar now resolves apple-touch-icon, PNG <link rel="icon">, or og:image directly from the station’s own homepage and caches it locally in Hive — zero third-party proxy, and kept inert in widget tests until main() initializes it so timer tests stay deterministic.
  • European ICY encodings (IcyMetadataService): Shoutcast/Icecast streams frequently send track metadata in Windows-1252 or ISO-8859-1 rather than UTF-8. Added strict UTF-8 validation with Windows-1252/ISO-8859-1 fallback, ICY NUL trimming, and double-encoded UTF-8 mojibake repair (ö → ö).
  • Stream & route fixes: Migrated bundled Absolute Radio stations from retired sharp-stream.com hosts to Bauer’s stream-ar.hellorayo.co.uk (carrying aw_0_1st.skey), treated dock, remoteSubmix, and carAudio route disconnects like Bluetooth disconnects to fix wired Android Auto unplugging, and enabled Apple’s approved com.apple.developer.networking.multicast entitlement so iOS discovers local DLNA/UPnP servers automatically.
  • Settings consolidation: Collapsed 12 flat Settings sections into 5 grouped Material 3 cards inside a centered 720 px column, moved Recording options to RecordingSettingsScreen with a live summary row, moved achievement notification toggles into BadgesScreen, and cached PackageInfo.fromPlatform().

By the Numbers

  • 1,680+ unit & widget tests passing across test/ (up from 1,624 in v1.3.0), zero analyzer issues
  • 3 native desktop power-management implementations (Windows 11 EcoQoS, macOS App Nap, Linux RLIMIT_NICE-guarded setpriority)
  • 5 clock typography styles (incl. custom 7-segment LED painter) + 1 custom Analog clock painter
  • 120 s Lissajous burn-in drift cadence shared across full-screen artwork overlays
  • 12 → 5 grouped Material 3 Settings cards inside a 720 px max-width layout
  • feedFormat = 4 podcast catalogue version triggering automatic one-time <itunes:season> / <itunes:episode> backfill

Lessons

  1. Test release minification and missing-store-service devices together. ProGuard/R8 stripping a third-party store SDK looks like “store SDK init returned false”, and any fallback into Google Play Billing on non-Play Android hardware can spin indefinitely.
  2. Store submission status is not public availability. Developer APIs often report a rollout as "completed" the moment the bundle enters review; verify what end users actually see on the storefront and double-check via platform in-app update APIs.
  3. Power policy belongs with lifecycle and audio state. A minimized desktop player shouldn’t run at normal priority while paused, and shouldn’t starve audio decoders on efficiency cores while streaming — splitting into normal, lowPowerAudio, and lowPowerIdle fits all three desktop OSes cleanly.

Radiophonia 1.3.2 is live from radiophonia.app (including the web app at radiophonia.app/live/). Direct-download artifacts are published on the Radiophonia v1.3.2 release page.