-
Notifications
You must be signed in to change notification settings - Fork 639
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): Back button fix for SDK28 #225
Conversation
@janpio Travis CI seems to be failing for an unrelated reason. Would this be a blocker for merging this PR? Thanks for your help :) |
Yes, but I can fix that in a minute. 🕙 |
And reopen so that Travis tries to build a merge to the now fixed |
@janpio I'm assuming the pipeline is blocked for some reason? Any chance we can get this merged in the next day or two? Thanks! |
The builds will run, just takes "some" time (unfortunately out of our control). And no, no guarantee when this will be merged. But as we just did a release, it won't be quick after the merge to be released anyway. We'll have to do some cleanup of issues an Pull Requests first. |
@janpio Thanks for the update, I might use my fork in the mean time as it's blocking my app releases. |
I have same problem. Any plan to release this fix soon? |
This does NOT fix the issue for me. I am running an Ionic 3 app and it only seems to fix the issue when I'm on navigation root level. As soon as I push a page onto the nav stack and use the hardware back button, the app activity is still being destroyed. When reopening the app, it restarts completely. Has someone actually done a root cause analysis or how did this fix come about? There are a fair few breaking changes in Android 9. It may have something to do with one of those. |
OK, I'll try to find time this weekend. Basically, it's an When using a lower Target SDK, there's no issue. I have no idea whether this is even caused by the splashscreen plugin. I just ended up in this repo from here. Looking at the proposed fix though, I'm not sure I understand what the assumed root cause was and how the fix addresses it. It seems a bit like a random trial-and-error workaround. But maybe I'm missing something. |
@janpio, I've figured out why my app is still crashing. I am using another plugin (NativePageTransitions) that also calls the function View#setVisibility(int). So, I can confirm that running this function (on UI thread or not) is indeed causing the issue. This "fix" basically just prevents the plugin from calling the function when running on API level 28 or higher. This isn't really a fix, right? I'm sure there was a point to calling that function... I've been trying to find out why on API level 28 it suddenly seems to be an issue to run |
The code has been there since the pplugin was created in 2014 when the splashscreen functionality was extracted from As I understand it, the webview is hidden / made invisible when the splashscreen is initially shown. Later on hiding the spinner (!?), it is made visible again. As the splash is over the webview anyway, this probably is not really necessary - and so this fix here "works". My total ad hoc theory: Since API level 28 the webview has to be visible for the back button handler to be initialized, or making it invisible changes its characteristics in some other way. But as my Android is pretty rudimentary as well, no real idea. |
Found where this code was initially added: apache/cordova-android@21a34a8#diff-f0fbc2da5463e5a0ada4128307a33c33R237 - 2011! So this is a really old part of |
OK, great. Good to hear that this is a fix then in case of this plugin. Guess I'll need to somehow figure out what to do with the other plugin as I need those native page transitions. Unfortunately that plugin isn't maintained anymore. @ all, if anyone has an idea as to why |
(To be honest I don't fully understand where this visibility thing is undone, cordova-plugin-splashscreen/src/android/SplashScreen.java Lines 186 to 200 in 05d8f9a
Fork it :/ |
@janpio Yep, I think you're right. When the loading spinner stops, the webview is shown again and then the splash is removed.
The thing is that the native page transitions plugin does actually need to set the visibility before and after every page transition. May just have to switch to using CSS animations... |
What would happen if the code for hiding the WebView was removed for all Android versions? So why does it even exist? |
You tell me ;) See #225 (comment) |
As far as I can see in the code sample from 2011, the WebView was made invisible in all cases (not only when the Splash Screen was active). I cannot find any reason why it exists in this PR: apache/cordova-android#134 or here: 50e4887 So to me, it remains unclear why it has been made. My problem is that I have nearly no experience in Android development, so maybe I simply don't yet know a certain important concept here. Is any of the authors of the commits mentioned above still active? Maybe, we could ask them... |
Hi guys, So, is not suficient only modify the file "SplashScreen.java" from directory "plugins" of our project cordova. After, is necesary copy this file in all locations inside directory "platforms/android". I'm very happy, problem solved. :) |
This PR where you commented is for that commit @juanludukeboss - but the problem is we don't know if this has any side effects and nobody could explain why it is necessary, which is why we are hesitant to just merge this. |
What you say will be difficult to know beforehand. You will have to update your plugin and test the result. This is much better than the Back button is failing. I can to see that my Splash loads perfectly, just started the App and when it is suspended also. So, I don't see nothing bad. All working perfect in Android 9 and old versions. Regards. |
I add this, cordova build error |
Same thought here. I guess we have fork that commit into our projects until the maintainers decide on a solution |
I remove plugin. Add plugin this fork (https://github.com/prageeth/cordova-plugin-splashscreen.git). Error if build android: ... SplashScreen.java:101: error: cannot find symbol |
Hi, if you have this error
For remove this error when you build Android you need put in your file "config.xml" from your Cordova project the attribute xmlns:android="http://schemas.android.com/apk/res/android" in the node "widget". |
For remove this error when you build Android you need put in your file "config.xml" from your Cordova project the attribute xmlns:android="http://schemas.android.com/apk/res/android" in the node "widget". |
Works, thanks |
I've just landed up with the same issue after updating my target Sdk to Android 28. (Updated: Confirmed that using the fork fixes this issue. Also note that for folks facing this error (as reported above):
It is not sufficient just to add |
@janpio @prageeth I've created a sample project that uses prageeths fork. Steps
|
I have 3 apps in production with my solution and all working ok in Android 9 and old versions. My solution is very simple and working perfectly |
But this now shows the application before its loaded? Are you facing this issue? |
Correction to my comment. The workaround is not the of the issue. After further debugging. The issue with "not popping" back to root is to do with the the deeplink code. |
Just came to confirm that this fork is working for me. |
Thanks @bnfrnz . I was also having the same issue. Once the native transition plugin is removed and the new plugin for splashscreen installed, its working fine. But can anyone tell what is the permanent solution for this issue. coz I need Native Transition Plugin to be installed. |
@IntellectBizMobility, we needed custom page transitions as well and ended up writing them ourselves using CSS animations. Here an example for a vertical slide:
Then, in your app.component.ts register your transition to your config:
And then use it like so:
You can pretty much build whatever transition you want. It's really just CSS animations wrapped in JavaScript. In theory, they may be less performant than the native transitions but we didn't see any issues with newer phones. As far as I remember, the native page transitions plugin isn't being maintained anymore, so we were actually happy to remove it, as keeping it just promises more issues down the road. The whole Cordova ecosystem is quite bad in that a lot of plugins (even really basic ones like this splash screen) aren't maintained properly. And frameworks like Ionic 3 (who are reliant on Cordova plugins and claim to offer a "curated" set of them) don't do anything about it either. I mean, it's free... and that's great... but it's also quite pointless if every other time some library is being updated something breaks and no one fixes it. |
Should be solved with 66d1e00 |
Platforms affected
Android
Motivation and Context
Fixes #186
Description
Back button not working correctly on Android for SDK28, more details in the linked issue.
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)