SFSafariViewController fires didCompleteInitialLoad: delegate before load completes, and always reports success

Originator:james.reggio
Number:rdar://22569408 Date Originated:09/03/2015
Status:Open/Duplicate Resolved:Duplicate of 22340386
Product:iOS SDK Product Version:iOS 9.0 (13A4325c)
Classification:Other Bug Reproducible:Always
 
[Want to discuss? Get in touch with me @jamesreggio.]

SFSafariViewController will send the safariViewController:didCompleteInitialLoad: message to its delegate almost immediately following initialization of the browser—it always fires before the initial page finishes loading, and it will fire even if the page never loads.

We expected this message to fire around the time that the window.load event fires within the browser, and we expected the boolean argument to indicate whether the page loaded successfully (i.e., with a 200 HTTP status). As it presently stands, we cannot derive any useful information about the state of the SFSafariViewController from this message, other than that it didn't crash.

Steps to Reproduce:
1. Instantiate a SFSafariViewController and assign a delegate that implements the SFSafariViewControllerDelegate protocol.
2. Navigate to the following types of URLs (expected results are listed below for each):
  a. http://ThisWillFailDNSResolution.co
  b. a simple page with no redirects that returns a 200 HTTP status
  c. a heavy page with no redirects that returns a 200 HTTP status
  d. a page that provides a [301, 302, 303, 307, 308] HTTP status redirect to a 200 HTTP status response
  e. a page that returns a 404 HTTP status

Expected Results:
a. (DNS failure) ~immediate message with NO boolean
b. (simple 200) ~immediate message with YES boolean
c. (slow 200) message when page is loaded, with YES boolean
d. (30x redirects) message when final 200 page is loaded, with YES boolean
e. (404) message when page is loaded, with NO boolean

Actual Results:
For all cases, the current implementation will immediately deliver the message with the YES boolean.

Version:
iOS 9.0 (13A4325c)

Notes:
This other radar describes the problem with the boolean always being YES for 404 HTTP statuses: https://openradar.appspot.com/22340386

Configuration:
iPhone 6 Simulator in Xcode 7.0-beta6 (7A192o)

Comments

UPDATE: Resolved as duplicate

(Resolved as duplicate of: https://openradar.appspot.com/22340386)

As I went to prepare a simplified repro app, I realized that this Radar was filed in error. In our app, all of our links were passing through an initial tracking server, which was returning a 200 OK with a JavaScript-based redirect.

I've attached our simplified repro app, which uses a simple HTTP service to test the delegate callback for a variety of use cases. Perhaps you'll find it useful. We used it to confirm that:

  1. didCompleteInitialLoad: fires at the time that the window.load event fires within the browser, which is desirable.
  2. The boolean argument is YES regardless of HTTP status, which is being tracked in the other Radar (#22340386).

(The code for the repro app is available here: https://github.com/jamesreggio/SFSafariViewControllerPlayground)

By james.reggio at Sept. 9, 2015, 7:55 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!