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

Assertion Failure when using file URLs #47

Closed
kenjitayama opened this issue Dec 23, 2020 · 8 comments
Closed

Assertion Failure when using file URLs #47

kenjitayama opened this issue Dec 23, 2020 · 8 comments
Assignees

Comments

@kenjitayama
Copy link

I get this assertion failure when using file URLs.

Fatal error: Only support HTTPURLResponse: file Atlantis/Packages.swift, line 209

It can be reproduced with this code in an iOS app.

if let url = Bundle.main.url(forResource: "Info", withExtension: "plist") {
  let task = URLSession.shared.downloadTask(with: url)
  task.resume()
}

In our app, many resources are retrieved from a web server, while some are bundled in the app.
For a specific kind of resource, we want to use the same implementation for web and bundled file, which uses URLSessionDownloadTask.
It would be helpful if this assertionFailure is removed.

@NghiaTranUIT NghiaTranUIT self-assigned this Dec 23, 2020
@NghiaTranUIT
Copy link
Member

Thanks for opening this issue. I'm looking at it and remove it as possible 👍

@NghiaTranUIT
Copy link
Member

NghiaTranUIT commented Dec 23, 2020

Hey @kenjitayama,

Can you share with us:

  1. Which iOS are you using?
  2. If you don't mind, can you provide a sample of your URL?

I tried to reproduce but it's working fine (Proxyman 2.15.1, iOS 14 and Atlantis 1.4.3)

        let url = URL(string: "https://proxyman.io/img/background/proxyman-dashboard-home.png")!
        let task = URLSession.shared.downloadTask(with: url)
        task.resume()
        let url = URL(string: "https://proxyman.io/img/background/proxyman-dashboard-home.png")!
        let task = URLSession.shared.downloadTask(with: url) { (_, response, error) in
            if let error = error {
                print(error)
                return
            }
            if let response = response as? HTTPURLResponse {
                print(response)
            }
        }
        task.resume()

Both URLSessionDownloadTasks are still working

Screen Shot 2020-12-23 at 10 15 25

@NghiaTranUIT
Copy link
Member

One more thing, when the assertionFailure occurs, can you print out the type of response variable?

The easier way is that you set the breakpoint at Atlantis/Packages.swift, line 209 and type po response to see the type and content.

@kenjitayama
Copy link
Author

@NghiaTranUIT Thanks for checking the issue!!

  1. Which iOS are you using?

I am using iOS 14.0 and Atlantis 1.4.3.

  1. If you don't mind, can you provide a sample of your URL?
    One more thing, when the assertionFailure occurs, can you print out the type of response variable?

Did this when assertionFailure occured (I changed the app name in the URL):

(lldb) po response
(NSURLResponse *) <0x283ec00e0> <NSURLResponse: 0x283ec00e0> { URL: file:///private/var/containers/Bundle/Application/CC649D79-6DC8-4B10-A4BA-E01A39E2275E/Example.app/Info.plist }

You need to use a file:// URL to reproduce.

@NghiaTranUIT
Copy link
Member

Thanks. I'm able to reproduce this bug. Fixing now 👍

@NghiaTranUIT
Copy link
Member

@kenjitayama please check out the 1.5.0 version, which I've released (https://github.com/ProxymanApp/atlantis/releases/tag/1.5.0)

It fixes your problem 👍 Thank you and Merry Christmas 🎉

Screen Shot 2020-12-23 at 13 20 30

@kenjitayama
Copy link
Author

@NghiaTranUIT Thanks for the quick fix!
Confirmed the issue is resolved in our app.
It's nice that we could see file:// URLs in Proxyman too 👍
Merry Christmas 🎄

@NghiaTranUIT
Copy link
Member

Glad to know it works 🎉

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

2 participants