简体   繁体   English

为什么我的 react-native 应用程序在录制时在后台终止(iOS,RN 0.63.3,Expo-Av 9.2.3)

[英]Why is my react-native app terminating in the background while recording (iOS, RN 0.63.3, Expo-Av 9.2.3)

Hello你好

I'm having an issue in my React Native app where audio recordings are sometimes mysteriously terminated while the app is in the background.我在我的 React Native 应用程序中遇到一个问题,当应用程序处于后台时,录音有时会神秘终止。

This happens only in ~1/10 user sessions after variable amounts of time anywhere from 5 to 50 minutes into the recording.这仅发生在大约 1/10 的用户会话中,在录制后的 5 到 50 分钟的可变时间之后。

Additional context is below.附加上下文如下。

I've been banging my head on this for weeks without progress.几个星期以来,我一直在努力解决这个问题,但没有任何进展。 Any thoughts on what could be causing this issue or where I should further investigate would be greatly appreciated.任何关于可能导致此问题的原因或我应该进一步调查的地方的任何想法将不胜感激。

Example Scenario示例场景

  1. Release-mode user begins an audio recording in our app, navigating them to the "recording in progress" screen发布模式用户在我们的应用程序中开始录音,将他们导航到“正在录音”屏幕

  2. User returns to the iPhone home screen and locks their phone.用户返回到 iPhone 主屏幕并锁定他们的手机。

  3. Five minutes later, the user turns on the screen to confirm that the orange active recording indicator is still visible in the status bar.五分钟后,用户打开屏幕以确认橙色的活动录音指示器在状态栏中仍然可见。

  4. Another five minutes go by.再过五分钟 go。 The user turns on the screen to see that the orange active recording indicator is no longer visible (but this only happens roughly 1 in 10 times)用户打开屏幕看到橙色活动录制指示器不再可见(但这只发生了大约十分之一)

  5. User unlocks their phone and returns to our app.用户解锁他们的手机并返回到我们的应用程序。 They are now back to the home screen instead of the active recording screen.他们现在回到主屏幕而不是活动录制屏幕。

Prior Investigation:事先调查:

  • Bugsnag has no uncaught errors (nor helpful clues) for this user during this session. This includes no reports of OOM errors. Bugsnag 在此 session 期间没有针对此用户的未捕获错误(也没有有用的线索)。这包括没有 OOM 错误报告。
  • Neither Crashlytics nor Xcode Organizer crash logs reveal any crashes during the time window of the mysterious termination. Crashlytics 和 Xcode Organizer 崩溃日志均未显示在神秘终止期间 window 期间的任何崩溃。
  • None of the user's Jetsam event logs for the day mention our app.当天用户的 Jetsam 事件日志都没有提到我们的应用程序。

Info about how recording works in our app有关录音在我们的应用程序中如何工作的信息

  • We record audio and upload it to our server in ~1m chunks.我们录制音频并将其以 ~1m 块的形式上传到我们的服务器。
  • Audio chunks are saved to the device before uploading is attempted and deleted upon successful upload.音频块在尝试上传之前保存到设备,并在成功上传后删除。
  • We use ffmpeg to extract 1m chunks of audio without stopping our recording session to avoid being suspended in background.我们使用 ffmpeg 提取 1m 的音频块而不停止我们的录音 session 以避免在后台暂停。

Additional User Context额外的用户上下文

  • Problem occurs on both iPad and iPhone.问题出现在 iPad 和 iPhone 上。 Unknown if it occurs on android.不知道它是否发生在 android 上。
  • Problem occurs on both old and new devices, from iPhone 7 to iPhone 14.从 iPhone 7 到 iPhone 14,新旧设备都会出现问题。
  • Users anecdotally state that the problem occurs mostly in low-connectivity environments用户反映 state 问题主要出现在低连接环境中

Environment环境

expo-env-info 1.0.2 environment info:
System:
OS: macOS 12.3
Shell: 5.8 - /bin/zsh
Binaries:
Node: 15.13.0 - ~/.nvm/versions/node/v15.13.0/bin/node
npm: 7.7.6 - ~/.nvm/versions/node/v15.13.0/bin/npm
Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
API Levels: 23, 28, 29, 30, 31
Build Tools: 29.0.2, 30.0.2, 31.0.0
System Images: android-29 | Google Play ARM 64 v8a, android-30 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7935034
Xcode: 13.3/13E113 - /usr/bin/xcodebuild
npmPackages:
react: 16.13.1 => 16.13.1
react-native: 0.63.3 => 0.63.3
react-native-web: ^0.16.3 => 0.16.5
npmGlobalPackages:
expo-cli: 4.3.4
Expo Workflow: bare

Root causes and solutions根本原因和解决方案

1) Mixpanel (love them,) iOS SDK had a bug. 1) Mixpanel(爱他们,)iOS SDK 有一个错误。 occasionally causing background terminations after 30 seconds.偶尔会在 30 秒后导致后台终止。

For context, Mixpanel uses a background task to flush event updates to server every time app enters background.对于上下文,每次应用程序进入后台时,Mixpanel 使用后台任务将事件更新刷新到服务器。 Additionally, iOS automatically terminates apps when a background task has not finished after 30 seconds.此外,当后台任务在 30 秒后仍未完成时,iOS 会自动终止应用程序。

For some reason, these Mixpanel event flushes were sometimes exceeding 30 seconds causing app terminations.出于某种原因,这些 Mixpanel 事件刷新有时会超过 30 秒,从而导致应用程序终止。

2) Background Out of Memory terminations. 2) 背景 Memory 终止。

Apple gives very few hints when apps are terminated.当应用程序终止时,Apple 很少给出提示。 Using Embrace.io (awesome company,).使用 Embrace.io(很棒的公司)。 I was able to begin measuring occurrences of out-of-memory terminations from the background (BOOMs).我能够从后台 (BOOM) 开始测量内存不足终止的发生。

Profiling with react native tools, I was able to identify that even in the background, app re-renders and redux actions in response to Firestore listeners were causing significant CPU usage.通过使用 React Native 工具进行分析,我能够确定即使在后台,应用程序重新呈现和响应 Firestore 侦听器的 redux 操作也会导致大量 CPU 使用。 Terminating unnecessary listeners and unmounting most screens when entering the background allowed us to significantly decrease background CPU usage, improving battery efficiency and virtually eliminating BOOMs在进入后台时终止不必要的侦听器并卸载大多数屏幕使我们能够显着降低后台 CPU 使用率,提高电池效率并几乎消除 BOOM

Happy to elaborate more if anyone has specific questions.如果有人有具体问题,我们很乐意详细说明。 Spent a looooot of time on this problem.在这个问题上花了很多时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么升级到 0.63.3 后命令“react-native run-ios”构建失败? - Why does command 'react-native run-ios' build fail after upgrade to 0.63.3? iOS 日期选择器在 react-native 0.63.3 中的奇怪行为 - Strange behavior of iOS datepicker in react-native 0.63.3 在 iOS 上使用 expo 响应原生 statusBar - react-native statusBar with expo on iOS 带有 React-native (expo) 的 IOS 版 Google 登录 - Google SignIn for IOS with React-native (expo) 在React-Native Expo中购买应用程序吗? - In App Purchases in React-Native Expo? 使用iOS启动屏幕作为react-native的应用程序背景 - Use iOS launch screen as app background in react-native Expo-AV 音频在 Android 播放时崩溃 - Expo-AV Audio crashing on Android on play 应用程序在后台时未收到通知(iOS react-native) - Not receiving notification when app in background (iOS react-native) 尝试在 React Native 中将 mp3 文件作为参数传递时出现错误。 我该如何解决这个问题? 我正在使用 Expo-av 作为参考 - Trying to pass an mp3 file as a parameter in React Native and I am getting errors. How can I resolve this problem? I am using Expo-av for reference 为 react-native ios 应用程序构建 ci/cd 管道:如何在 gitlab-ci 中运行 expo 构建? - Building a ci/cd pipeline for react-native ios app: How to run expo build in gitlab-ci?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM