Skip to content
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

Restart on split-screen #744

Closed
kamilSarapuk opened this issue Jun 12, 2019 · 11 comments
Closed

Restart on split-screen #744

kamilSarapuk opened this issue Jun 12, 2019 · 11 comments

Comments

@kamilSarapuk
Copy link

I've got a problem with Cordova, when user turn on split-screen on Android.

When it happen, app restarts and it is fine. Problem is when user changing screen size on login (MsAdal Plugin - other activity). Boths activities are restarted, but if user fill credentials and this page is closed, he sees first page on mainActivity. It is possible to kill all other activities and reopen only main?
I lost couple of days to find a way out, but with no result. I found that this problem exist in all new project, so I don't know what I can provide from code.

@janpio
Copy link
Member

janpio commented Jun 13, 2019

Can you provide some more information?
What kind of split screen? What exactly does your app do? What exactly does your user do?

@kamilSarapuk
Copy link
Author

What kind of split screen?

I mean standard android split-screen. Like described in this article:
https://www.techradar.com/how-to/how-to-use-split-screen-on-android

What exactly does your app do?

It's simple app, which after "device ready ", start a new "log in" activity (with MsAdal plugin), where user can login to ADFS. If user go back to main activity, it get info about result, and if it is suceess it navigates user to other page.

What exactly does your user do?

User, after getting logging page, turn on split screen. This restarts "log in" activity. In result, user still can put credentials on it.
After closing "log in" activity, main activity is resumed and size change is detected. In result main activity is restarted and again start "log in"activity.

From user point of view: he change size, put credentials and after confirm, app show him again logging page. It looks very susspicious, that's why I have to change it.

I don't need "split-screen" functionality, but I wasn't enable to turn it off neither.

@janpio
Copy link
Member

janpio commented Jun 13, 2019

My Android devices unfortunately don't seem to support this.

I think the main complication to reproduce (and possibly find a fix for) this might be the MsAdal plugin. Can you think of a super simple app that does not use this plugin but still can replicate the behavior you describe?
A minimal reproduction repository would really help to debug and later fix this issue. More information on how to create one: https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md

@janpio
Copy link
Member

janpio commented Jun 13, 2019

On a more general note:
This seems to be used to disable splitscreen: https://developer.android.com/guide/topics/ui/multi-window#resizeableActivity, e.g. https://stackoverflow.com/a/40267246/252627 There might be a way to configure this via config.xml, or write a tiny plugin that does the same via its plugin.xml.

@kamilSarapuk
Copy link
Author

I've already got both links, and I try to add 'android:resizeableActivity="false"' via configuration, but in all devices and simulators I have, it doesn't prevent resize or user actions, but only shows terribly ugly warning, like this one:
https://www.howtogeek.com/wp-content/uploads/2016/09/Screenshot_20160923-124924.png.pagespeed.ce.crdEqG_j8q.png
I found information that this message is displayed when the split screen function is enforced by the phone's settings, but I did not change this function on the devices.

I will leave this message if I can not do anything more.

@breautek
Copy link
Contributor

breautek commented Jun 13, 2019

Just noting that I'm able to reproduce this Android 9. While in multi-window, it seems like the webview restarts everytime the window is resized. Personally in my apps, I would like to be able to disable multi-window... but I feel like this is a feature that should be disabled by default especially if it doesn't work out of the box.

I'll post some information below that might be helpful. I may tackle this over the weekend if time permits.

Android documentation about multi-window can be found here

Specifically the resizableActivity attribute docs can be found here

There are two important bits of information...

If this value is false, and the user attempts to launch the activity in multi-window mode, the activity takes over the full screen.

So android:resizableActivity="false" should work...

Note: If you build a multi-orientation app that targets API level 23 or lower, and the user uses the app in multi-window mode, the system forcibly resizes the app. The system presents a dialog box warning the user that the app may behave unexpectedly...

But it sounds like it will only work if the target SDK is >= 24. The current master in cordova-android has target SDK set to 28 so we should be safe there. But the behaviour @kamilSarapuk described appears to match this notice.

@dpogue
Copy link
Member

dpogue commented Jun 13, 2019

See also https://issues.apache.org/jira/browse/CB-10841

@breautek
Copy link
Contributor

I was able to confirm on a simple app (created by using cordova create) adding android:resizableActivity="false" to the <application> tag will completely disable multi-window/split-screen mode on android.

With android:resizableActivity="false" android does not provide a split screen option, and if I attempt to split screen another app with the cordova app, android will open the cordova app in full screen with a message "This app does not support multi-window mode"

I'm not sure what is involved in making Cordova work in multi-window mode (that is, to prevent the webview from reloading when entering multi-window mode or when the windows resized). So I feel like android:resizableActivity="false" should be set by default. Shall I make a PR?

Note that you can accomplish the same thing by adding the following to the config...

<widget ... xmlns:android="http://schemas.android.com/apk/res/android">
    <edit-config file="AndroidManifest.xml" target="/manifest/application" mode="merge">
        <application android:resizeableActivity="false"></application>
    </edit-config>
</widget>

@kamilSarapuk
Copy link
Author

Thank you for help, it worked. I searched the repository to check what I was doing wrong: when typing "edit-config" I had to do some syntax error, and the effect of the message itself gave android: resizeableActivity = "false" set in activity.

@ttencate
Copy link

I believe this issue is still valid and should be reopened: split screen still triggers a restart of the activity. According to https://issues.apache.org/jira/browse/CB-10841?focusedCommentId=15246741&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15246741 this can be fixed simply by adding smallestScreenSize|screenLayout to android:configChanges in AndroidManifest.xml.

@janpio
Copy link
Member

janpio commented Jul 14, 2019

Please open a new issue with a proper description @ttencate, seems like @kamilSarapuk considered his individual problem fixed - but very possible that there is a more general one still present.

breautek added a commit to breautek/cordova-android that referenced this issue Aug 6, 2019
breautek added a commit to breautek/cordova-android that referenced this issue Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants