-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(android): prevent BaseActivity to stay with exitOnClose:false #14159
Draft
m1ga
wants to merge
1
commit into
master
Choose a base branch
from
androidCloseWindows
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m1ga I think this will need some additional condition checks for
exitOnClose
.exitOnClose: false
window, though it prevents to show splash screen, but it will close entire activity stack too which is not intended.exitOnClose: true
window, it may not dispose JS runtime properly as it's terminating stack without checking whether JS script is running or not.We need more testing on this change as it can break the behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is to close the window in the
exitOnClose:false
state because we've ended up in a place where we shouldn't be. So I don't respect thefalse
part and close the app so it has to restart next time. This is better then it's being stuck at the splashscreen.If you close the windows in a normal speed it won't end up in that if case.
exitOnClose: true
shouldn't change with the PR as it won't go into that if condition.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exitOnClose: false
won't work as intended with this PR.There are likely two scenarios an app would want to do on back-press:
exitOnClose: false
on first window and open home-intent on its back button press.enableOnBackInvokedCallback
which we can improve in future releases.exitOnClose
default value in this PR.Or is there any other case I am missing here that you are trying to achieve? 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently with
exitOnClose: false
it will put the app to the background and not close it when you "close" the last window. This works fine unless you close two windows quickly. Then it is not putting the app to the background but stays at the splashscreen/base actitvity. Check the demo code + videos.This is the whole issue I'm trying to fix here by "force closing" the app when we end up in that state. So it will be the same as
exitOnClose:true
for this edge case.The issue is a due to the system close animations and closing it quicker before the system close animation is done and everything is cleaned up.
Normally it will end up in a state where you have 1 window in the stack and Ti will put it to the background because of
exitOnClose:false
. But when you do it quickly it will end up with a zero window stack and it doesn't know what to do here.The video under
Different approach:
will show you another way where I've blocked the "back" until the animation is done. But for me that looks a bit like the app is not doing what you want it do do.And to test it you have to have normal window animations enabled on your phone and close the 2nd window + 1st window very quickly 😄 I think it's an edge case but since Ti is that performant that you can close them so quickly we should add the fix for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking an excerpt from your last comment:
Another solution: Rather terminating the app, we launch the home-intent in this case in SDK itself, because then it still keeps the same purpose of setting
exitOnClose: false
, the app won't be killed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m1ga Thanks for confirming the
androidback
.Your only concern is now that the app didn't close when you called
win1.close()
, it's because you have to reset itsexitOnClose: true
again.Ideally
root Ti.Window (win1)
won't be closed programmatically just like that. It will be closed if users really want to open another screen, e.g. signing out the app and opening login/signup screen.win1.close()
, either:exitOnClose: true
again onwin1
before calling it'sclose()
.To summarise, you have to take care of adding/removing
androidback
and settingexitOnClose
depending on what you want to achieve.If you want, we can jump over a Slack call and test things out together to see if there's really an edge case we cannot handle with current SDK features (obviously after normal working hours 😊).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m1ga would love to hear your further updates if there's still any open issue!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while the JS code works it's just a workaround that I don't want to add in all apps or have other devs find this out and add it.
As a app dev I just want to set
exitOnClose:false
and no think about switching it or usingandroidback
. So the issue still exists without this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your use case which is possible when users presses back button too fast.
My whole point is that this PR is changing the meaning of
exitOnClose: false
in this edge case as apps will exit anyways.However, if you still want to take this forward, then I would strongly suggest you to verify following scenarios after the app is terminated in this edge case:
These scenarios are very common ways to invoke the app and should work same as with current SDK.
We should rather find a proper way to put the app to background no matter how fast the back button is pressed. I will try to give this issue a proper fix in coming weeks (not very soon though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the infos. Will test those cases 👍
If we find the real lifecycle issue it would be great! No rush here, no user report so far about this edge case. Thank you for taking the time to answer with all the details 👍