firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
828 stars 428 forks source link

iPhone 13 cannot access Internet on cellular data when Firebase added to project #1261

Closed HarrisonShort closed 2 years ago

HarrisonShort commented 2 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

We are finding an issue where iPhone 13s cannot access the Internet on cellular data. It works as expected on wifi. Initially we did not suspect Firebase, but after investigating further, and beginning a "process of elimination" tactic, we found that adding Firebase to the Unity project causes the issue to occur.

We have found this issue on iPhone 13 Pro and Pro Max, but do not have access to other phones in the iPhone 13 family.

The error log:

2022-04-27 14:31:16.130521+1000 CellularDataTest[37665:3565489] Task <45F280FC-4A76-4838-8A54-18A3E24809AA>.<1> HTTP load failed, 0/0 bytes (error code: -1009 [1:50]) 2022-04-27 14:31:16.134395+1000 CellularDataTest[37665:3565489] Task <45F280FC-4A76-4838-8A54-18A3E24809AA>.<1> finished with error [-1009] Error Domain=NSURLErrorDomain Code=-1009 "The internet connection appears to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x28151d1a0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_NSURLErrorNWPathKey=unsatisfied (Denied over cellular interface), interface: pdp_ip0[lte], ipv4, dns, expensive, _kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <45F280FC-4A76-4838-8A54-18A3E24809AA>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <45F280FC-4A76-4838-8A54-18A3E24809AA>.<1>" ), NSLocalizedDescription=The internet connection appears to be offline., NSErrorFailingURLStringKey=https://httpbin.org/get, NSErrorFailingURLKey=https://httpbin.org/get, _kCFStreamErrorDomainKey=1}

Unfortunately I'm not actually sure what the issue could be, but it does seem to only occur when Firebase is added to the project.

Steps to reproduce:

I have provided two Unity projects, which are identical except that one has Firebase implemented. I have also included an XCode builds for both projects, which are in the Build folder in each project root. I am running XCode 13.3.1 on my Macbook Pro. I have removed the GoogleService-Info.plist from the Firebase project and have changed the bundle ID for privacy reasons. https://drive.google.com/file/d/15iXvZNokPoFHgeQdkGk3k077yn2oveCc/view?usp=sharing

On No-Firebase project:

  1. Run build on iPhone 13 on wifi
  2. OnAwakeScript component on Main Camera will send a GET request to https://httpbin.org/get
  3. Request should be successful
  4. Run build on iPhone 13 on cellular data
  5. OnAwakeScript component on Main Camera will send a GET request to https://httpbin.org/get
  6. Request should be successful

On Firebase project:

  1. Run build on iPhone 13 on wifi
  2. OnAwakeScript component on Main Camera will send a GET request to https://httpbin.org/get
  3. Request should be successful
  4. Run build on iPhone 13 on cellular data
  5. OnAwakeScript component on Main Camera will send a GET request to https://httpbin.org/get
  6. Above error should appear

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)? What's the issue repro rate? (eg 100%, 1/5 etc) Yes, 100%. I had a project with Messaging and another project with Dynamic Links added as I was recently investigating another Firebase issue we were experiencing, and the same issue occurs in both of those projects as well.

Thanks for your attention on this!

DellaBitta commented 2 years ago

Hi @HarrisonShort,

We were able to reproduce this on an iPhone 13 but not a simulator. Is that simliar to your experience?

Additionally we received error code 1003, not 1009. Have you seen that in any of your test runs?

Thanks!

HarrisonShort commented 2 years ago

Thanks for your quick response @DellaBitta!

We were able to reproduce this on an iPhone 13 but not a simulator. Is that simliar to your experience?

I've just given that a test in the XCode simulator, and I can't seem to recreate it there either. However, I can't see a way to simulate using cellular data, so that could be the reason why.

Additionally we received error code 1003, not 1009. Have you seen that in any of your test runs?

Unfortunately for this issue I have not seen an error code other than 1009. In the 1003 error log, does it mention "denied over cellular interface" at all?

paulinon commented 2 years ago

Hi @HarrisonShort,

I missed a step in my original testing. It turns out that the bundle ID in the Unity implementation and the one in Xcode aren't the same. After correcting this, there were no errors encountered when using either WiFi or cellular data. That being said, could you confirm if there's no mismatch with your bundle IDs?

HarrisonShort commented 2 years ago

Hi @paulinon, thanks for your reply.

Unfortunately at the moment I don't have access to the device, but the issue is occurring on our main Unity project, which has not had it's bundle ID change for the duration of the app's development. I will have access to the device over the weekend, so I'll give it another once over and a test. I actually took the bundle ID and GoogleService-Info.plist from our main project for the purposes of the test projects. Is there any change that there could be an issue related to the bundle ID itself?

On top of that, this may indicate an issue with my XCode setup, so I'll get another member of the team to try making a build to see if the issue persists there.

paulinon commented 2 years ago

Hi @HarrisonShort,

It's possible that the cause of the issue could lie in your configuration, so fixing the bundle ID mismatch may make a difference. I'll be looking forward to your results.

If that didn't work, I'd like to confirm a few things:

google-oss-bot commented 2 years ago

Hey @HarrisonShort. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

HarrisonShort commented 2 years ago

Apologies for the lateness of my response, I've been dealing with a whole range of tasks and unfortunately haven't been able to give this issue the attention I'd like to.

  • Could you confirm if a similar issue persists when using an Android device?

We have not seen this on any Android devices and have not received any reports from users. Having said that, when the issue occurs on iPhone 13, it does not show up on our external bug-tracking software, so I can't rule it out entirely.

  • Kindly provide the OS versions of the devices that have encountered the issue.

Both iPhone 13 devices that we have seen this on are on iOS 15.4.1.

  • Do you happen to have any iOS devices lower than iPhone 13? If so, could you confirm if they exhibit a similar behavior?

We have not seen this behaviour on any device lower than iPhone 13.

I'll be doing some more investigation into this tomorrow, as I'll finally have access to an iPhone 13 again.

paulinon commented 2 years ago

Thanks for the additional information, @HarrisonShort. I look forward to your investigation results.

Additionally, version 8.10.1 of the SDK has been released recently. Could you try this out and see if it makes a difference?

HarrisonShort commented 2 years ago

Alright, so I just did another extensive test. What I seem to have found is that it's occurring with our main app's specific bundle ID and GoogleService-Info.plist.

What I did was create a new Firebase project with a new app, with the bundle ID com.harrisonshort.debuggingproj. I tested fresh projects (set up with the same script and scene from the earlier provided projects) with both Firebase 8.9.0 and 8.10.1. The request was sent successfully in both builds, whether on wifi or cellular data.

I then created fresh projects, but used the bundle ID and GoogleService-Info.plist of our main app. In both builds (one for each Firebase version), wifi successfully sent the request, but on cellular data the request failed.

Unfortunately that means I'm a little unsure of where to go from here. Seems like we could try to create a new app on Firebase, though I'm unsure about the potential downtime that may force the app to undergo. I could also try providing the GoogleService-Info.plist, though I'm unsure about the privacy/security implications of that. Is there anything you could suggest?

Thanks for your continued attention to this!

paulinon commented 2 years ago

Hi @HarrisonShort,

Given that there's no issue with the new Firebase project, my guess is that there's a dissimilarity in the keys in the GoogleService-Info.plist files you used. Could you try using a recent download of your original project's GoogleService-Info.plist pointing to your main app's bundle ID and see if it made a difference?

HarrisonShort commented 2 years ago

The empty projects did actually use freshly downloaded GoogleService-Info.plist files. I just updated the file for our main app project and I did notice that there was actually a discrepancy, the ANDROID_CLIENT_ID specifically, but otherwise the files were identical. Unfortunately, making a new build of our main app using this updated file did not return a different result.

paulinon commented 2 years ago

Thanks for the update, @HarrisonShort. It looks like something in the backend is causing this behavior and not the SDK. You may report this to Firebase Support so that one of our agents can get in touch with you regarding this issue. That being said, I'll be closing this for now.

HarrisonShort commented 2 years ago

Thanks for your help on this @paulinon