App killed when starting a foreground activity on some devices
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- android
- Lĩnh vực
- mobile
Hướng nghiên cứu
Bắt đầu với bản demo camera của NativeScript và tái hiện vòng đời trên một Huawei Mediapad T5 bị ảnh hưởng. Theo dõi các sự kiện activityDestroyed và thoát của NativeScript khi khởi chạy camera hoặc Android PrintManager, sau đó so sánh kết quả với hành vi mong đợi là activity của NativeScript vẫn có thể sử dụng được sau khi khởi chạy một foreground activity.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C++
- Star
- 563
- Fork
- 144
- Merge trung bình
- 10 giờ 46 phút
- Pull request đã merge (30 ngày)
- 14
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NativeScript/android
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
NativeScript/android#2039 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
NativeScript/android#2024 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
NativeScript/android#2020 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
NativeScript/android#2019 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
NativeScript/android#1986 ·
Tất cả issue của NativeScript/android
Issue tương tự
-
Website Doc Typo Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 92/100
autowarefoundation/autoware_universe#13413 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
automated-analysis bug memory-safety
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100