Skip to content

fix(#315): inject AnalyticsManager into full-player sheets (Mac crash)#314

Merged
cassio-rossi merged 1 commit into
release/v5from
fix/mac-fullplayer-crash
Jul 21, 2026
Merged

fix(#315): inject AnalyticsManager into full-player sheets (Mac crash)#314
cassio-rossi merged 1 commit into
release/v5from
fix/mac-fullplayer-crash

Conversation

@cassio-rossi

Copy link
Copy Markdown
Collaborator

Problem

The podcast full player crashed on Mac only ("My Mac — Designed for iPad") when opened by tapping the mini player.

Root cause

FullPlayerView and ChaptersView each read analytics via @EnvironmentObject var analytics: AnalyticsManager. Both are presented through .sheet. On the iOS-app-on-Mac runtime the sheet is hosted in a separate presentation context that does not inherit the root .environmentObject(viewModel.analytics), so the first access traps:

Fatal error: No ObservableObject of type AnalyticsManager found.
7  FullPlayerView.actions.getter
21 FullPlayerView.player.getter
22 FullPlayerView.body.getter

iPhone/iPad inherit the environment object across the sheet boundary, so the crash was Mac-only.

Fix

Re-inject analytics into the presented sheets, mirroring the existing DeepLinkNewsDetailView pattern (which already re-injects .environmentObject(viewModel.analytics) into its sheet):

  • PodcastMiniPlayerModifier reads @EnvironmentObject analytics (present in the main hierarchy) and forwards it into the FullPlayerView sheet.
  • FullPlayerView forwards it into the nested ChaptersView sheet (same latent crash when opening the chapter list).

The speed popover captures analytics directly in its closures rather than doing its own environment lookup, so it needs no change.

Verification

  • ✅ Build succeeded (iPhone 17 simulator; the fix is platform-agnostic Swift).
  • ✅ SwiftLint --strict on both changed files — 0 violations.
  • ⚠️ No unit test: this is SwiftUI-runtime environment propagation across a sheet boundary, not unit-testable (PodcastLibrary's test target can't exercise it).
  • 📱 Needs on-device Mac re-run to confirm the crash is gone (repro is: mini player → tap to open full player; then open the chapter list).

Note / potential follow-up (not fixed)

SystemVolumeView wraps MPVolumeView, which may misbehave on the iOS-app-on-Mac runtime. Because the analytics crash fired first, that path was never reached, so it's unverified. If the volume row misbehaves once the full player opens on Mac, that's a clean separate ticket.

Notes

  • No develop branch exists — branch is based on release/v5; PR targets release/v5.
  • No linked issue number (per request), so the commit/PR use a plain fix(podcast) scope; CI's title check may expect fix(#NNN) — rename if it enforces that.

🤖 Generated with Claude Code

The podcast full player crashed on Mac (Designed for iPad) when opened
from the mini player: FullPlayerView and ChaptersView read analytics via
@EnvironmentObject, but they are presented in .sheet contexts that do not
inherit the root .environmentObject(analytics) on the iOS-app-on-Mac
runtime, so the first access trapped with "No ObservableObject of type
AnalyticsManager found". iPhone and iPad inherit it, so it only crashed
on Mac.

Re-inject analytics into both presented sheets, mirroring the existing
DeepLinkNewsDetailView pattern:
- PodcastMiniPlayerModifier forwards analytics into the FullPlayerView sheet.
- FullPlayerView forwards analytics into the nested ChaptersView sheet.

Co-Authored-By: Claude <noreply@anthropic.com>
@cassio-rossi
cassio-rossi force-pushed the fix/mac-fullplayer-crash branch from 889ad69 to 5103399 Compare July 21, 2026 20:06
@cassio-rossi cassio-rossi changed the title fix(podcast): inject AnalyticsManager into full-player sheets (Mac crash) fix(#315): inject AnalyticsManager into full-player sheets (Mac crash) Jul 21, 2026
@cassio-rossi
cassio-rossi merged commit 40a0a3d into release/v5 Jul 21, 2026
1 of 3 checks passed
@cassio-rossi
cassio-rossi deleted the fix/mac-fullplayer-crash branch July 21, 2026 20:08
cassio-rossi added a commit that referenced this pull request Jul 21, 2026
Rebuilt against the merged release/v5 tree (2828 nodes, 5293 edges,
200 communities). Transient AST cache and dated snapshots left untracked.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant