App killed when starting a foreground activity on some devices
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 30/100
- Issue 類型
- 缺陷
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- android
- 領域
- mobile
研究方向
從 NativeScript 相機示範開始,在受影響的 Huawei Mediapad T5 上重現生命週期。啟動相機或 Android PrintManager 時,追蹤 activityDestroyed 和 NativeScript 結束事件,然後將結果與預期行為進行比較:啟動前景 activity 後,NativeScript activity 仍保持可用。
由索引模型根據 Issue 內容生成。
描述
Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):
- CLI: 6.5.0
- Cross-platform modules: 6.5.1
- Android Runtime: 6.4.1
- Plugin(s):
@nstudio/nativescript-checkbox
nativescript-bitmap-factory": "^1.8.1",
nativescript-bluetooth
nativescript-camera
nativescript-drawingpad
nativescript-feedback
nativescript-fonticon
nativescript-geolocation
nativescript-iqkeyboardmanager
nativescript-localize
nativescript-modal-datetimepicker
nativescript-print-zebra
nativescript-printer
nativescript-sqlite
nativescript-sqlite-commercial
nativescript-sqlite-encrypted
nativescript-toasty
nativescript-zip
Describe the bug
On some devices, at least on Huawei Mediapad T5, when I start a new activity that goes on the foreground, the NativeScript activity gets killed. When I go back, the NS activity restarts.
After some investigation, I concluded that it's a battery management issue. Android always kills app activities put in the background to minimize battery usage, but on some devices (mainly Huawei from what I've found) this mechanism is very aggressive and kills the activity immediately after it goes in the background. The Android activityDestroyed event and NS exit event are not called.
I have two scenarios:
- Opening the camera with nativescript-camera plugin. The NS activity is killed but the camera still works, allowing me to retrieve the photo uri on restart.
- Printing with the system service PrintManager. In this case, when the NS activity is killed the print tool closes too. To the user, it looks like a crash.
My goal is to prevent the perceived crash at least on the second scenario. Is there a way to release enough resources when the activity is paused?
Allowing the app to ignore battery optimization and managing manually launch/app launch doesn't solve the issue.
To Reproduce
Launch the nativescript-camera demo on an affected device.
Expected behavior
The NS activity is not killed after it starts a new activity.
- 主要語言
- C++
- 星號
- 563
- 分支
- 145
- 平均合併
- 10 小時 45 分鐘
- 30 天內合併 PR
- 11
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
NativeScript/android 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 76/100
NativeScript/android#2053 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 38/100
NativeScript/android#2039 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 48/100
NativeScript/android#2024 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 20/100
NativeScript/android#2020 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 42/100
NativeScript/android#2019 ·
維護者通常 1 天內回覆
查看 NativeScript/android 的全部 Issue
相似的 Issue
-
upstream update
難度 2/5 1-3 小時 新手友好度 75/100
conan-io/conan-center-index#31098 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 86/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
ml-explore/mlx-c#136 ·
-
bug chart-audit
難度 1/5 1 小時以內 新手友好度 92/100
維護者通常 1 天內回覆