[iOS] RouterExtensions.back() fails silently after app lock/suspend mid-navigation — component stuck, native back button unresponsive on resume
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- angular, ios, typescript
- Lĩnh vực
- mobile-dev
Hướng nghiên cứu
Bắt đầu với RouterExtensions.back(), Frame.topmost().goBack() và vòng đời tạm dừng/tiếp tục của iOS trên thiết bị vật lý bằng cách sử dụng cửa sổ tái hiện 150ms đã mô tả. Theo dõi trạng thái bị gián đoạn của UINavigationController và frame NativeScript, sau đó xác minh rằng có thể thử lại thao tác điều hướng hoặc các trạng thái native, frame và Angular router được đồng bộ hóa lại sau khi tiếp tục.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[iOS] RouterExtensions.back() fails silently after app lock/suspend mid-navigation — component stuck, native back button unresponsive on resume
Environment
- CLI: 9.0.5
- Cross-platform modules (
@nativescript/core): 8.9.9 - Android Runtime: 8.9.2
- iOS Runtime: 8.9.4
- Plugin(s):
@nativescript/angular - NativeScript-Angular: 17.0.0
- Angular: 17.0.8
Describe the bug
This is a runtime error on iOS only.
When RouterExtensions.back() is called (e.g. on form submit after an async API operation) and the user locks the phone or backgrounds the app within the same moment, the navigation silently fails. On resume:
- The component that triggered the back navigation is still on screen
- The native ActionBar back button (top-left iOS back chevron) is also completely unresponsive
- No exception is thrown, no crash, no error log
- Calling
router.back()again on resume causes the call to repeat but navigation never completes Frame.topmost().canGoBack()returnstruebutFrame.topmost().goBack()has no visible effect
The app is permanently stuck on that page until force-quit and relaunch.
Console output observed during a single "submit + lock phone" cycle (3 resume attempts):
back Called
Keyboard hidden
super.back Called
back Called
Keyboard hidden
super.back Called
back Called
Keyboard hidden
super.back Called
super.back() fires even when the app is in the background. NavigationEnd never fires. Angular router url still points to the source page on resume. Frame.topmost().goBack() on resume is silently ignored and the native back button stops responding entirely.
To Reproduce
Setup:
A custom RouterExtensions subclass wrapping back() in a setTimeout for iOS keyboard dismiss (a common and necessary iOS pattern — navigating without first dismissing the keyboard causes visual glitches):
@Injectable() export class BaseRouterExtension extends RouterExtensions { IOS_KEYBOARD_DISMISS_DELAY = 150;
override back(options?: BackNavigationOptions) {
this.zone.run(() => {
hideKeyboard();
if (isIOS) {
setTimeout(() => {
super.back(options); // fires even when app is suspended
}, this.IOS_KEYBOARD_DISMISS_DELAY);
} else {
super.back(options);
}
});
}
}
Navigation triggered by a signal/effect on API success:
effect(() => { if (this.successOperation()) { this.navigateBack(); } });
async navigateBack() {
await this.onStopTextToSpeech();
this.router.back();
}
Steps:
- Navigate from Page A → Page B (a form/edit screen)
- On Page B, submit the form — this triggers an async API call, on success
router.back()is called - Lock the phone (press power button) within ~150ms of the
back()call - Unlock the phone and resume the app
- Observe: still on Page B — the programmatic back and the native ActionBar back button both do nothing
Most reliable reproduction (near 100% hit rate):
The setTimeout(150ms) creates a guaranteed window. Lock the phone immediately after tapping Submit before the toast or transition appears.
Expected behavior
Either:
RouterExtensions.back()/Frame.topmost().goBack()called on resume should complete the interrupted navigation, OR- The native
UINavigationControllerstate and NativeScript frame/Angular router state should be re-synced automatically on resume so that navigation can be retried from JS
Sample project
Unable to provide a Playground link as the issue requires a physical device lock action to reproduce (Simulator behaves differently for lock/sleep events). A minimal reproduction would be:
- Page A navigates to Page B
- Page B calls
RouterExtensions.back()inside asetTimeout(150) - Lock the physical device during that 150ms window
- Resume — Page B is stuck and native back button is unresponsive
Additional context
What was attempted as workarounds — none fully resolved the issue:
| Approach | Result |
|---|---|
| Check Application.inBackground in setTimeout | Unreliable — flag not always set before setTimeout fires depending on lock timing |
| Own _isAppInBackground flag via suspend/resume events | Race condition — suspend event fires after navigateBack() call in some sequences |
| Snapshot router.url before back(), compare on resume | URL comparison is accurate, but Frame.topmost().goBack() on resume still silently fails |
| Frame.topmost().goBack() directly in resume handler | No visual effect — native back button is also unresponsive at this point |
| RouterExtensions.navigateByUrl(previousUrl) on resume | Pushes a new page onto the stack instead of popping — incorrect behaviour |
| page.on('navigatedFrom') to detect native completion | Does not fire when navigation is interrupted by lock |
The native UINavigationController appears to enter a broken/stuck state after a lock-interrupted navigation transition that cannot be recovered from the JavaScript layer with currently available APIs.
Questions for the team:
- After a lock-interrupted
UIViewControllerpop, is there a supported way to re-trigger or complete the navigation from JS? - Is the native
UINavigationControllerinstance exposed anywhere so we can callpopViewControllerAnimated:directly as a fallback? - Is there a navigation transition completion hook (equivalent to
UINavigationControllerDelegate.navigationController:didShowViewController:animated:) accessible from NativeScript?
Related issues:
- https://github.com/NativeScript/nativescript-angular/issues/1596 — Back navigation broken after suspend/resume in TabView + nested frame scenario — closed/fixed in 2018 via PR https://github.com/NativeScript/NativeScript/pull/6528. The current issue reproduces on a simple single-frame stack with no TabView and is not addressed by that fix.
- Ngôn ngữ chính
- TypeScript
- Star
- 55
- Fork
- 13
- Merge trung bình
- 16 phút
- Pull request đã merge (30 ngày)
- 1
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/angular
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
NativeScript/angular#170 · 1 bình luận ·
-
My types are gone Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
NativeScript/angular#163 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
NativeScript/angular#158 · 1 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
NativeScript/angular#155 ·
-
NativeScript/angular#154 · 1 người được giao ·
Tất cả issue của NativeScript/angular
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
Add: Star Sports 2 Telugu HD Đang mởcheck:passed streams:add
Độ 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 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100