38
  1. I have a HTML page with a Download app button. When clicked by an iOS user, it redirect the users to the App Store via itms-services. The link I used here is:

    window.location.replace("itms-apps://itunes.apple.com/app/id578505616");
    

    It looks like so on a mobile browser: Mobile webpage with Download button

  2. Facebook/Pinterest has an in-app browser which asks for the user's consent before redirect the user out of their app in the form of an Alert box with Cancel or Open app, which Open app opens the external link. It looks like this: Mobile webpage with Download button embedded in Facebook

It looks like this with the Alert box: FB embedded browser with alert box

Assuming the user is using an iOS device. The expected behavior here is when the Open app button is clicked, the user gets redirected to the App Store app. However, we are seeing about a 10 seconds delay before the actual redirection happens.

See videos below:

https://www.youtube.com/watch?v=_dgh7v-IsK8

https://www.youtube.com/watch?v=_LFHeRnBFgg

https://www.youtube.com/watch?v=82Y-kj-pMyw

Notes:

  1. I can't seem to reproduce this at all times. It is only reproducible sometimes. Sorry!
  2. Once a device is delayed for the first time, all subsequent links to AppStores will be fast, until roughly 1 day late. Rebooting the phone and/or clearing the browser cache and/or reinstall Facebook/Pinterest does not help reproducing this.
  3. I tried to replace the itms-apps:// link with https://itunes.apple.com/us/app/trusper-tips-tutorials-how/id578505616?mt=8, but we were still experiencing the delay from time to time.
  4. The delay seems to be exactly 10 seconds.

Why does this delay occur? This seems like a bad user experience.

My current theory is that the problem is on the Apple side. The reason being, once the Open app button is clicked, it is out of the hand of our website, as well as Facebook/Pinterest app. I presume, once the button is clicked, iOS is handling the actual context switch from one app to another. Therefore, it suggests that either the system call actually opening the URL is hanging, or the system call opening the App Store app is?? However, I haven't been able to prove either one to be true or false. Does anyone have a better explanation?

[Edit 04/02/2015] I can confirm this problem still exists as of today on my phone (iPhone 5S w/ iOS 8.2). I did some further research and found this article which I think is suggesting that this is a iOS system-related bug: OpenUrl freezes app for over 10 seconds

Community
  • 1
  • 1
ethangui
  • 1,285
  • 11
  • 15

1 Answers1

4

As there is no proper documentation on how it works, it is hard to pinpoint the cause of it.

Let me advance a theory.

  • Opening an app from browser causes a context switch; indeed from browser to App Store. So for the very first time it'd cost some time, while in subsequent times it will open faster as it will get opened from cache.

  • If you consider AppStore uses Keep-alive connection between iOS AppStore in device and iOS AppStore Server for the first time socket opening in server would seem higher than the subsequent times as subsequent request would reuse the same connection.

  • If the app is removed from the cache then it'd again take some time for the app to open and there would be a little network delay as the app would have lost the cookie for keep-alive connection then the app would have to endure the socketing opening cost.

  • There are also other factors like Safari hanging, resulting in some delay. You can read how Safari can be messed up here.

  • iOS doesn't have garbage collection, only things like ARC (Automatic Reference Counting). Each has its own advantages and drawbacks. Sometimes these drawbacks can surface and cause some problem; nothing is to be ruled out. For example a memory leak or app-crash might leave dangling pointers.

  • Technically, using itms-apps should give a little advantage over plain iTunes url because itms-apps should narrow down the search; itms-apps mean iTunes Music Store-apps. A plain iTunes URL may be a Book (iBook), Music (iTunes), App (Appstore), etc ... so iOS might have to decide which app to launch.

I hope this helps.

Community
  • 1
  • 1
Durai Amuthan.H
  • 31,670
  • 10
  • 160
  • 241
  • Thanks for your answer however we experienced the same 10 seconds delay on both itms-apps and http links. It is certainly plausible that this behavior has something to do with caching, as after hanging for once, it will not hang again for about a day or so, no matter if one kills the app or restarts the phone. That said, the cache here helped to reduce the impact of the underlying bug - it doesn't explain or solve this issue. Furthermore, I can argue the cache is generally not useful for new user acquisition - as the 10 seconds delay has already turned away many potential users. – ethangui Apr 25 '15 at 02:12
  • @ethangui - Yes you are right.The caching plays critical role in transition between browser and the app-store.When the app is not opened from cache and it is going to be slow.This is common to everybody and nothing we can do about it as it is out of our reach.see `[UIApplication sharedApplication] openURL:]` delay it is in the iOS app so we can try out some workaround But with browser what we can do is design the site(that hosts `itms://apps`) that doesn't hurt the browser by considering the guidelines in http://goo.gl/KVaA6P. so that it doesn't introduce any additional burden causing delay. – Durai Amuthan.H Apr 25 '15 at 17:26
  • @ethangui - You could even ensure `Caching and Etag` are implemented in your site to avoid unwanted roundtrips to server.Just a thought – Durai Amuthan.H Apr 26 '15 at 11:03
  • I don't think we are on the same page here. The delay happens before the browser app is opened, rather than what you are hypothesizing here when after the browser app is opened, before the app is opened. Therefore, caching on our webpage will not help the delay. – ethangui Apr 29 '15 at 01:00
  • i.e. the delay would still be there if the link we are opening is google.com, as someone pointed out in the comment section of this question: http://stackoverflow.com/questions/19356488/openurl-freezes-app-for-over-10-seconds – ethangui Apr 29 '15 at 01:03
  • @ethangui - If you are having `pre iOS 8` version of the devices.You could simply attach the device with system and open the `iPhone Configuration Utility`.and click the on your device and go to `console` and try to reproduce the issue.It'll give you the iOS logs that might help you If you are using `iOS 8.0` or above you could open the xcode then choose `Window` and then `Devices` choose your device from the side bar and in the right side choose `View Device Logs` .. – Durai Amuthan.H Apr 29 '15 at 09:03
  • I'm afraid the method you described might not be practical as this behavior is observed roughly once per day at different times... I wish I could reproduce this issue more reliably. – ethangui Apr 30 '15 at 18:06
  • 1
    @ethangui - I can understand your problem with this.The best you can do is Report it as a Bug in Open Radar( `http://goo.gl/qjMLOj`) or Bug Reporter(`http://goo.gl/TupH4m`) and track it there probably apple technician would respond to you.In the mean time If I stumble upon anything useful related to this I will let you know on this thread. – Durai Amuthan.H May 02 '15 at 17:45
  • Thanks @Duraiamuthan.H, I have just reported this as a bug via Bug Reporter as per your suggestion. I will update this thread once I hear anything back from Apple. – ethangui May 04 '15 at 18:39