-
Notifications
You must be signed in to change notification settings - Fork 94
session.reload()
will sometimes open in Mobile Safari instead
#121
Comments
(I'm part of @auctionet-mob.) We tried reproducing it by programmatically calling |
I reproduced this bug in iOS 12.1 simulator on the current master branch (8b0ff21) It took a lot of effort. I clicked manually hundreds of times, tried using automator to click about 1000 times. I was about to give up, pressed the button a few more times and Safari finally opened. |
I notice this issue as well, instead of loading a url in a WKWebView, Turbolinks instead hands its off to Safari. Is this still an ongoing issue? Xcode 10, iOS 12.1.3 |
It's still an ongoing issue – I've seen it in the wild recently on Turbolinks 5.2.0, Xcode 10.2, iOS 12.2. Just tried in our app on my phone and I was able to trigger it in a matter of seconds of going back and forth between self-reloading tabs. |
I investigated this further today and think I might have found why this is happening. I wasn't able to fully solve it but hope that my findings can help or inspire someone else who wants to give this a try. When doing two When This method will then replace the When the This causes the Here's the order of the events I observed:
I'm not sure how to best solve this but one idea would be to have calls to I tried to implement this solution but couldn't find a way to pass an identifier when starting a visit that |
@calleerlandsson we are seeing this issue as well in our app, but never happens in the Basecamp app I am using daily. I would love to hear any thoughts on how to mitigate this! |
Sorry, I could have swore I responded to this thread before. We've never seen it in Basecamp, and as far as I know, no reports of it. There are only two places Turbolinks opens a link in Safari, and it would be helpful to know which of these is being triggered here:
I'm curious for the people that are experiencing this issue, do you have your own As a workaround, you could try implementing the Session delegate's turbolinks-ios/Turbolinks/Session.swift Line 314 in 0cdd4bd
|
Thank you very much, @zachwaugh! Next time @calleerlandsson and I work on our Turbolinks app we'll try to delve into this again and report back. |
Just a note here. If what @calleerlandsson reported is correct, the workaround suggested by @zachwaugh will not work. As it looks like it's the Visit.swift |
We're experiencing this issue as well. I followed @zachwaugh 's suggestion and implemented the openExternalURL method that now checks if the host is actually an external host or not. Looks like it's working (but not sure because I find this bug hard to reproduce) As an aside: as a Rails developer (and novice iOS developer at best) I'd pay a good amount to take a look at a more elaborate example app (like Basecamp's app). The included example in turbolinks-ios is very helpful, but it's also really bare-bones. It'd really help me to have an example with more use cases for typical Rails apps. |
@zachwaugh, yes we are also setting our own I can confirm that it is the Do you think the root cause of this issue will be resolved in an upcoming version of Turbolinks iOS? |
I work with @calleerlandsson – the fix we tried was func session(_ session: Session, openExternalURL URL: URL) {
// This attempts to work around a bug in Turbolinks that causes session.reload() to sometimes open a page in Safari. For more info on this, see this issue: https://github.com/turbolinks/turbolinks-ios/issues/121
if MyAppURLChecker.isMyAppURL(URL) { // <- Replace this, obviously…
assertionFailure("This URL should not be opened in Safari")
return
}
UIApplication.shared.open(URL)
} We could reproduce the issue just prior to the fix, and after adding the fix we could trigger the assertion failure (which would just be a silent return in production, of course) – so hopefully this successfully worked around the issue. UPDATE: One fairly big gotcha with this solution is that it also applies if you ever do |
We're seeing what appears to be a timing issue, where if we trigger
session.reload()
at the wrong time, it will open the page in Mobile Safari instead of in the app.We've seen it in our own app by triggering
session.reload()
on tab changes and then changing tabs quickly. We managed to come up with a repro in the demo app, but it's not for the faint-fingered. We added a nav bar button that callssession.reload()
. Then we pressed it a lot and managed to reproduce the issue:Here is the diff:
Our impression is that this seems to happen if we reload right at the start of the page rendering, but we're not at all sure.
The text was updated successfully, but these errors were encountered: