[Bug] Android frames are missing from frame stack after backpress and app resume
Issue Description
In android 12 and later, root launcher activities are no longer finished on Back press. See https://developer.android.com/about/versions/12/behavior-changes-all#activity-lifecycle
However, {N} core overrides backpress and removes frames from stack, thinking that the activity will finish. Then, user attempts to launch the app and it will simply resume without recreating views and frames will still be missing from the stack.
That is because the frame stack implementation is very old and did not consider the more recent android 12 behaviour.
The issue affects Frame.topmost() and Frame.getFrameById().
This can be replicated in apps with multiple frame instances as back press makes sure core keeps at least a single frame in the stack.
Reproduction
- Launch an app with a frame that has an
idin android 12 or later - Log result from
Frame.getFrameById(id)which should print the frame view - Press back to close application
- Launch app again and it will still be in the last navigated page
- Log result from
Frame.getFrameById(id)and it will be undefined
Relevant log output (if applicable)
Environment
No response
Please accept these terms
- I have searched the existing issues as well as StackOverflow and this has not been posted before
- This is a bug report
- I agree to follow this project's Code of Conduct
Source: NativeScript/NativeScript