podverse / podverse-rn

Podverse mobile app written in React Native for iOS, Android, and F-Droid
https://podverse.fm/about
GNU Affero General Public License v3.0
219 stars 36 forks source link

Issues in resuming app from sleep on iOS (CarPlay) #1650

Open GilOliveira opened 1 year ago

GilOliveira commented 1 year ago

Describe the bug This is a tricky bug to describe because, although it happens a lot, it's tricky to reproduce. I've seen this issue happen mostly with CarPlay, but I'm not sure it's CarPlay-specific. Basically, if the phone is in sleep mode (screen off), loads of times Podverse can't resume a podcast, and the CarPlay app doesn't function properly (can't access podcast lists, can't resume the podcast). The majority of times the issue resolves by turning on the phone's screen (even without unlocking the phone).

To Reproduce Steps to reproduce the behavior:

  1. Don't use Podverse for a few minutes/hours and/or use other media apps.
  2. Turn on the ignition of a CarPlay-enabled car/headunit without interacting with the iPhone (assuring the screen doesn't turn on).
  3. Open the Podverse CarPlay app from the CarPlay home menu.
  4. Error behaviour varies: app can't load any podcasts (stuck on "Loading..." in the podcast list), or can't load podcast episodes, or it loads episodes fine but can't play them. Error behaviour is not consistent (doesn't happen all the times, doesn't always manifest in the same ways). Selecting a unlisted episode/podcast or having closed Podverse prior to entering the car increases the likelihood of reproducing the issue.

Expected behavior All CarPlay apps are expected to have complete functionality without any interaction with the iPhone (given they meant to be used in the car).

Screenshots Most frequent behaviour (the app opens, but gets stuck on "loading"): 563FAEC1-8763-4CC3-8F0C-7EC3DA54C4B1 App doesn't find any podcasts: 91F2A82F-CA84-400B-8248-80776D0D6B0F (Also notice on that instance the "Now Playing" icon, usually on the top right) doesn't even show up, that icon shows up sometimes when the iPhone detects the media the user was playing prior)

*Smartphone I've had this issue persist across iOS (so 16.2.*, 16.3) and Podverse versions (happens on the latest) and even iPhones (occurred on iPhone 13 Pro and iPhone 14 Pro)

Additional context This issue happens if the phone has been in sleep mode for a while and if the iPhone is connected to CarPlay without turning on the screen. Particularly common when using wireless CarPlay, as the user doesn't need to interact with the phone whatsoever to start CarPlay.

Not a React Native dev and have practically null experience with iOS development, but I'm aware iOS' battery management is particularly aggressive with apps that haven't been used in a few minutes. This issue may seem like it doesn't affect UX much, but it's particularly cumbersome with the user is driving and the Podverse CarPlay app doesn't work at all until the user turns on the iPhone's screen (illegal in most places).

mitchdowney commented 1 year ago

@GilOliveira thanks so much for the detailed bug report.

I was just chatting with @kreonjr about this, and given the fact we are using React Native, this may not be an easy fix...it seems as though iOS is suspending the bridge between the iOS and CarPlay instance of the app after inactivity, and then the CarPlay app loses the data that it gets through the iOS bridge.

Unfortunately, this issue may hang around for a while. I don't have an idea for a true fix aside from possibly re-writing all of our React Native logic as iOS Swift functions. That would be ideal, but I imagine it would be a lot of work, so I don't have a timeline for delivery.

If anyone has feedback or advice on how to handle CarPlay with a React Native bridge to avoid this issue I would greatly appreciate it.

GilOliveira commented 1 year ago

@mitchdowney @kreonjr no worries, thanks for your work!

mitchdowney commented 1 year ago

@GilOliveira as far as @kreonjr and I know, this is not an issue in our CarPlay implementation anymore. If you are still seeing this issue, please let us know and we will reopen it.