firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

Firebase Storage / Vertex AI: HTTP3 failures (-1005, -1017)

Open Kirow opened this issue 9 months ago • 6 comments

Description

I just moved from i9 Intel to Silicon M4. And now I see strange errors in my app during testing on files downloading. A lot of -1005 Connection Lost or -1017 cannot parse response with following lines like

nw_protocol_implementation_lookup_path [C38.1.1.2:2] No path found for 5410496762cbf3     <- com.apple.network
0x1178cf818 38 Server protocol violation 0x02                                             <- com.apple.cfnetwork h3connect
0x1178cf818 38 Control stream closed but connection is alive                              <- com.apple.cfnetwork h3connect

App iterate through the list of storage refs and tries to download (StorageReference.writeAsync(toFile:)) the file if it does not exist locally. Mostly it happens sequentially, sometimes a little bit in parallel. If file failed it will be moved to the end of queue and retries later. Failures happens on the same files multiple time and at some rare occasions it does download.

Error appears only on simulator on M4 laptop, it does work on old laptop and on real device. I've notice that simulator on M4 using http3, so I start proxy that does not support http3 - and it start working fine.

So my conclusion is that problem with HTTP3

I still investigating, but maybe someone will drop idea or solution to this problem.

Reproducing the issue

not available at this moment

Firebase SDK Version

11.11.0

Xcode Version

16.3 (16E140)

Installation Method

Swift Package Manager

Firebase Product(s)

Storage

Targeted Platforms

iOS

Relevant Log Output

MyCode.swift:46
 👀 Start downloading - 9bfjwHShMvRLjHJowCx7
11.11.0 - [FirebaseAuth][I-AUT000017] Has valid access token. Estimated expiration date:2025-04-08 18:28:36 +0000, current date: 2025-04-08 17:28:59 +0000
11.11.0 - [FirebasePerformance][I-PRF300005] URL length exceeds limits, truncating recorded URL - https://firebasestorage.googleapis.com:443/v0/b/******.appspot.com/o/PATH_TO_FILE_1.zip.
11.11.0 - [FirebasePerformance][I-PRF300005] URL length exceeds limits, truncating recorded URL - https://firebasestorage.googleapis.com:443/v0/b/******.appspot.com/o/PATH_TO_FILE_1.zip.
nw_connection_copy_connected_local_endpoint_block_invoke [C196] Connection has no local endpoint
nw_connection_copy_connected_local_endpoint_block_invoke [C196] Connection has no local endpoint
quic_conn_change_current_path [C196.1.1.1:2] [-e2ec972bce4de892] tried to change paths, but no alternatives were found
nw_connection_copy_connected_local_endpoint_block_invoke [C196] Connection has no local endpoint
nw_protocol_implementation_lookup_path [C196.1.1.1:2] No path found for 54fb7d625518029c
0x10a9d5e18 196 Server protocol violation 0x02
0x10a9d5e18 196 Control stream closed but connection is alive
nw_connection_copy_connected_local_endpoint_block_invoke [C198] Connection has no local endpoint
nw_connection_copy_connected_local_endpoint_block_invoke [C198] Connection has no local endpoint
quic_conn_change_current_path [C198.1.1.1:2] [-fc34761712275213] tried to change paths, but no alternatives were found
nw_connection_copy_connected_local_endpoint_block_invoke [C198] Connection has no local endpoint
nw_protocol_implementation_lookup_path [C198.1.1.1:2] No path found for 54ac50c7cc3bb4d
0x13b1af018 198 Server protocol violation 0x02
0x13b1af018 198 Control stream closed but connection is alive
nw_connection_copy_connected_local_endpoint_block_invoke [C200] Connection has no local endpoint
nw_connection_copy_connected_local_endpoint_block_invoke [C200] Connection has no local endpoint
quic_conn_change_current_path [C200.1.1.1:2] [-fcd7bf60df245c86] tried to change paths, but no alternatives were found
Task <02CDA635-F3B7-4625-970B-582603A62AD4>.<117> HTTP load failed, 2450/0 bytes (error code: -1017 [4:-1])
nw_connection_copy_connected_local_endpoint_block_invoke [C200] Connection has no local endpoint
nw_protocol_implementation_lookup_path [C200.1.1.1:2] No path found for d504b2162ebcddb1
Task <02CDA635-F3B7-4625-970B-582603A62AD4>.<117> finished with error [-1017] Error Domain=NSURLErrorDomain Code=-1017 "cannot parse response" UserInfo={_kCFStreamErrorCodeKey=-1, NSUnderlyingError=0x60000135c000 {Error Domain=kCFErrorDomainCFNetwork Code=-1017 "(null)" UserInfo={NSErrorPeerAddressKey=<CFData 0x6000064ad270 [0x1e6ebb4f0]>{length = 16, capacity = 16, bytes = 0x100201bb8efa4b0a0000000000000000}, _kCFStreamErrorCodeKey=-1, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <02CDA635-F3B7-4625-970B-582603A62AD4>.<117>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDownloadTask <02CDA635-F3B7-4625-970B-582603A62AD4>.<117>"
), NSLocalizedDescription=cannot parse response, NSErrorFailingURLStringKey=https://firebasestorage.googleapis.com:443/v0/b/******.appspot.com/o/PATH_TO_FILE_1.zip?alt=media, NSErrorFailingURLKey=https://firebasestorage.googleapis.com:443/v0/b/******.appspot.com/o/PATH_TO_FILE_1.zip?alt=media, _kCFStreamErrorDomainKey=4}
0x109881618 200 Server protocol violation 0x02
0x109881618 200 Control stream closed but connection is alive

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

Replace this line with the contents of your Podfile.lock!

Kirow avatar Apr 08 '25 17:04 Kirow

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Apr 08 '25 17:04 google-oss-bot

I got similar http3/QUIC issue on iOS simulator, specifically iOS v18.4, accessing storage.googleapis.com

matej-io avatar Apr 09 '25 07:04 matej-io

It's a bug in the 18.4 iOS simulator, see https://developer.apple.com/forums/thread/777999 for details.

weakfl avatar Apr 09 '25 09:04 weakfl

Ok, thanks. I was focused on the fact that I changed desktop arch and have not notice that I have different iOS and Xcode. Actually same problem on intel with 18.4 simulator and it does work correctly on the device with 18.4. But truth to be told - I haven't checked whether the device uses http3 or not.

So meanwhile I will not use 18.4 simulator during testing. But if I will need to use it Is there any simple way to disable http3? maybe something to Info.plist or Firebase configuration itself?

In general problem is understood and seems to be not related to the Firebase. Probably could be closed. I will leave this decision to the contributors.

Kirow avatar Apr 09 '25 11:04 Kirow

Thanks for the link, @weakfl. That thread pointed out a reasonable workaround that worked for the Vertex AI in Firebase SDK that was also impacted by this bug in URLSession (#14696).

@Kirow Unfortunately I'm not aware of any way to disable HTTP3. For now I'd recommend using the iOS 18.3.1 simulator from Xcode 16.2. I've been using the 18.3.1 simulator with Xcode 16.3 without any issues.

We'll also investigate whether a similar workaround to #14696 can be used in the Firebase Storage SDK but it depends on URLSession transitively, rather than directly, so we can't guarantee that it will work.

andrewheard avatar Apr 10 '25 01:04 andrewheard

The Xcode 16.4 release notes mention a fix to URLSession that look promising in addressing these errors: https://developer.apple.com/documentation/xcode-release-notes/xcode-16_4-release-notes#Simulator

ncooke3 avatar May 19 '25 17:05 ncooke3