[英]Why is my react-native app terminating in the background while recording (iOS, RN 0.63.3, Expo-Av 9.2.3)
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.任何关于可能导致此问题的原因或我应该进一步调查的地方的任何想法将不胜感激。
Release-mode user begins an audio recording in our app, navigating them to the "recording in progress" screen发布模式用户在我们的应用程序中开始录音,将他们导航到“正在录音”屏幕
User returns to the iPhone home screen and locks their phone.用户返回到 iPhone 主屏幕并锁定他们的手机。
Five minutes later, the user turns on the screen to confirm that the orange active recording indicator is still visible in the status bar.五分钟后,用户打开屏幕以确认橙色的活动录音指示器在状态栏中仍然可见。
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)用户打开屏幕看到橙色活动录制指示器不再可见(但这只发生了大约十分之一)
User unlocks their phone and returns to our app.用户解锁他们的手机并返回到我们的应用程序。 They are now back to the home screen instead of the active recording screen.他们现在回到主屏幕而不是活动录制屏幕。
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
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 秒,从而导致应用程序终止。
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.