Search Unity

UnityWebRequests on iOS sometimes get stuck indefinitely even with timeout set

Discussion in 'Scripting' started by nilsdr, Nov 26, 2020.

  1. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    Sorry, colors disappeared
     
  2. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    i've made the modifications to UnityWebRequest.mm as you suggested, but in my case the didBecomeInvalid is NOT invoked when the bug occurs.

    This is in the xcode log however:

    Code (CSharp):
    1. 2020-12-15 19:36:53.855979+0100 holomeet[541:39290] [tcp] tcp_output [C7.1:3] flags=[R.] seq=2402621881, ack=3839589854, win=8191 state=CLOSED rcv_nxt=3839589854, snd_una=2402621881
    2. 2020-12-15 19:36:53.857349+0100 holomeet[541:39290] Connection 7: received failure notification
    3. 2020-12-15 19:36:53.857551+0100 holomeet[541:39290] Connection 7: failed to connect 3:-9816, reason -1
    4. 2020-12-15 19:36:53.858167+0100 holomeet[541:39290] Connection 7: encountered error(3:-9816)
    5. 2020-12-15 19:37:15.954669+0100 holomeet[541:39289] [tcp] tcp_output [C8.1:3] flags=[R.] seq=1591377457, ack=1571664107, win=8180 state=CLOSED rcv_nxt=1571664107, snd_una=1591377457
    6. 2020-12-15 19:37:15.956525+0100 holomeet[541:39289] Connection 8: received failure notification
    7. 2020-12-15 19:37:15.956755+0100 holomeet[541:39289] Connection 8: failed to connect 3:-9816, reason -1
    8. 2020-12-15 19:37:15.957277+0100 holomeet[541:39289] Connection 8: encountered error(3:-9816)
    9. 2020-12-15 19:37:15.959287+0100 holomeet[541:39289] Task <E9131A3C-B91D-4217-97E5-14DF1E302FC0>.<6> HTTP load failed, 0/0 bytes (error code: -1200 [3:-9816])
    So, 9816 means errSslClosedNoNotify. Could this be something TLS related? Our unitywebrequest fetches some XML data from a private S3 endpoint, and uses HTTPS

    https://developer.apple.com/documen...sult_codes/errsslclosednonotify?language=objc

    Heres my modified unintywebrequest code:

    Code (CSharp):
    1. @implementation UnityWebRequestDelegate
    2.  
    3. - (void)URLSession:(NSURLSession *)session didBecomeInvalidWithError:(NSError *)error
    4. {
    5.     NSLog(@"NETWORK: %@", error);
    6. }
    7.  
    8. - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(nonnull NSURLResponse *)response completionHandler:(nonnull void (^)(NSURLSessionResponseDisposition))completionHandler
    9. {
    10.     NSLog(@"NETWORK: %@", response.URL);
    11.  
    12.     [self handleResponse: response task: dataTask];
    13.     completionHandler(NSURLSessionResponseAllow);
    14. }
    15.  
    After a succesful request, I can see the NETWORK: call with the url in the log. After the bugged request, neither of the NSLogs fires
     
    Last edited: Dec 15, 2020
  3. re-cheid

    re-cheid

    Joined:
    Apr 10, 2017
    Posts:
    34
    I can confirm, that everything works fine in iOS 14.1 while 14.2 as well as 14.3 are broken
     
  4. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    To those encountering this error, can you confirm your unitywebrequest tries to fetch from a https source, and do you see this in your logs:

    Connection 7: failed to connect 3:-9816, reason -1
     
  5. ANTONBORODA

    ANTONBORODA

    Joined:
    Nov 16, 2017
    Posts:
    52
    Same issue here, also using ARFoundation
     
  6. luke_avm

    luke_avm

    Joined:
    Mar 26, 2019
    Posts:
    10
    We're also seeing this issue. We use Vuforia Fusion, which makes use of ARKit. Our app worked fine on iOS 14, but not 14.2 or 14.3. I have been able to reliably reproduce the issue whenever the AR session is interrupted by a permission dialog, but it also happens intermittently otherwise.

    We have an app that's live on the App Store that's broken by this, so really hoping for a fix soon!
     
  7. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    bug report Case 1299301
     
  8. Eli1234

    Eli1234

    Joined:
    Jul 13, 2017
    Posts:
    24
    I can confirm - we're using https, and our logs show:

    Connection 40: received failure notification
    Connection 40: failed to connect 3:-9816, reason -1
    Connection 40: encountered error(3:-9816)
     
    nilsdr likes this.
  9. Eli1234

    Eli1234

    Joined:
    Jul 13, 2017
    Posts:
    24
    What versions of unity is everyone seeing this bug with? We started seeing it around when we upgraded from 2019.3 to 2019.4, so I assumed it was related. Now I’m wondering if it’s from iOS 14.2, and the unity upgrade was a coincidence.
     
  10. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    I tested 2019.4.4 and 2019.4.16. When i saw first thread message saying 2020.1.14f1 i stopped trying.
     
  11. altkey_ca

    altkey_ca

    Joined:
    Nov 2, 2014
    Posts:
    8
    We haven't tested the bug on older versions of Unity. We're on 2020.1.6f1
     
  12. luke_avm

    luke_avm

    Joined:
    Mar 26, 2019
    Posts:
    10
    We also haven't tested on other versions of Unity, but are currently on 2019.4.9f1
     
  13. luke_avm

    luke_avm

    Joined:
    Mar 26, 2019
    Posts:
    10
    Not sure if this is related to the bug, but we also see this error every time it fails:

    Code (CSharp):
    1. Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

    Could be a symptom of the issue though, rather than the root cause. Anyone else seeing this?
     
  14. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    I, once this :
    Code (CSharp):
    1. Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service
    But not always, it seemed like a broken thing among many others ...
     
  15. Eli1234

    Eli1234

    Joined:
    Jul 13, 2017
    Posts:
    24
    Yes, we see
    Code (CSharp):
    1.  
    2. Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
    3. Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service
    4.  
     
  16. jasonchown

    jasonchown

    Joined:
    May 17, 2017
    Posts:
    5
    We were experiencing what sounds like this exact same problem (iOS 14.2 + Unity 2020.1 + AR Foundation = UWR coroutine death) and have fixed our reproducible case by switching to HttpClient.
     
  17. Eli1234

    Eli1234

    Joined:
    Jul 13, 2017
    Posts:
    24
    To close the loop on this - we've just reproduced the issue using the build of our game that's live in the AppStore, which went through very thorough testing before release. That build was created using Unity 2019.3. To me that indicates this bug was not a result of us upgrading our project from Unity 2019.3 to Unity 2019.4, but actually a result of iOS 14.2 being released.
     
    dokyriy and nilsdr like this.
  18. altkey_ca

    altkey_ca

    Joined:
    Nov 2, 2014
    Posts:
    8
    Thanks for sharing. I'm surprise there are not more developers out there coming up with this problem as the games using ARFoundation and calling servers are probably having issues on 14.2+.
     
  19. altkey_ca

    altkey_ca

    Joined:
    Nov 2, 2014
    Posts:
    8
    @jasonchown Are you sure you've fixed the problem by using HTTPClient. We did the same, but the bug wasn't fixed. It might be that we’re also using UnityWebRequestTexture. So, in our tests, we did change UnityWebRequest for HTTPClient but, we did not change UnityWebRequestTexture (as the problem did not seem to come from this call).
     
    nilsdr likes this.
  20. Eli1234

    Eli1234

    Joined:
    Jul 13, 2017
    Posts:
    24
    we have also fixed the issue by switching to HttpClient. To be precise: we still see the bug, but only with areas of our network code that use UWR. Everything that depends on UWR stops working, and HttpClient continues.
     
  21. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    so some people logged a bug right, has Unity's QA reproduced it?
     
    Last edited: Dec 20, 2020
  22. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    Many plugins are using unitywebrequest ... :-( We can't change everything ... maybe yes ... but it's not the right way .... so Aurimas-Cernius let us know please how debug is going on, maybe we can help you:-(
     
  23. jhanawa

    jhanawa

    Joined:
    Feb 27, 2018
    Posts:
    1
    I'm running into a similar problem.

    I checked the communication when it failed with WhireShark.
    Different "Session ID" was set for "Server Hello" and "Client Hello". However, after the server returned "Server Hello Done", the client side did not return "Client Key Exchange" and it seemed to stop there.
     
  24. Abruzzi

    Abruzzi

    Joined:
    Feb 6, 2015
    Posts:
    44
    Yeah, we have the absolutely same problem, arkit, webrequests randomly broken on iOS 14.2+ :( We also use addressables and it breaks at the same time!
     
  25. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    I don't know what to do anymore, it is extremely important that it be fixed!
     
  26. apiotuch_unity

    apiotuch_unity

    Joined:
    Jun 28, 2019
    Posts:
    138
    @Unity any progress on this issue? I believe this is the issue I am encountering as well. Easily reproducible with an XR (3GB RAM) 14.2 and 14.3. Does not occur on XS Max for us.
     
    Last edited: Dec 29, 2020
  27. nlacroixAOD

    nlacroixAOD

    Joined:
    Jul 20, 2018
    Posts:
    20
    Does anyone know of updates on this or any issues/bugs to follow? We're experiencing the same issue others mentioned with AR/UWR and iOS 14.2+. Tested on an iPhone 7 and confirmed that 14.1 with the exact same code works fine but as soon as the device is upgraded to a version at or higher than 14.2 the issue is easily reproduced.

    @Aurimas-Cernius Any updates?
     
  28. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    IT IS INCREDIBLE THAT NO ONE ANSWER !!!!
     
    jgmakes likes this.
  29. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    Happy new year :) I was wondering if anyone has heard back from Unity QA about the bug?
     
  30. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    happy new year everyone, sorry for raising my voice but I had to work hard to replace everything with httpclient. And not everything is working yet ... no news from us
     
  31. apiotuch_unity

    apiotuch_unity

    Joined:
    Jun 28, 2019
    Posts:
    138
    We have the crashing occur with 14.2 and 14.3 using iPhone 7, XS Max, and XR. @Unity really would like to know what apple did to cause this issue.
     
  32. GoldARVR

    GoldARVR

    Joined:
    Oct 28, 2019
    Posts:
    6
    Same problem with ARFoundation 4.1.1, iOS 14.3, Unity 2019.4.11f.

    It seems I can still use POST method while in AR, but not PUT method ? And sometimes even without AR it will completely stop all current and futur UnityWebRequest, unless I restart the app.
     
    jgmakes likes this.
  33. Estyu2

    Estyu2

    Joined:
    Jul 30, 2018
    Posts:
    1
    We have the same problem with Vuforia fusion + iOS 14.2 or .3 + unity 2019.4.12.
    I can't believe we don't have a solution yet. This is a very serious problem for augmented reality companies!
     
  34. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    Just confirmed this still happens in all the latest branches:

    - 2019.4.17f1
    - 2020.1.17f1
    - 2020.2.1f1
     
  35. FOKSlab

    FOKSlab

    Joined:
    Jun 27, 2017
    Posts:
    30
    Same issue for me as soon as I updated my OS on my iPad : iOS14.2 with Unity 2019.3.4f1. It is a really annoying issue since my app need to read a remote file to start !

    Is last Unity version fixing that weird behaviour ?
     
  36. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    No, I still haven't seen a bug report with repro project for this.
     
  37. luke_avm

    luke_avm

    Joined:
    Mar 26, 2019
    Posts:
    10
    Hi @Aurimas-Cernius, I've just submitted a bug with a bare bones project for reproducing this issue. The case number is: 1304394

    I am able to reliably reproduce the issue in this project, but it is a tricky bug. Sometimes UnityWebRequest ceases to work the first time you send one, while other times the bug may only occur after making 50 or more UnityWebRequests.

    I hope you can help. Like others on this thread our app is completely unusable due to our reliance on AR and UnityWebRequests.

    Thanks!
     
    fegabe, nilsdr and altkey_ca like this.
  38. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  39. apiotuch_unity

    apiotuch_unity

    Joined:
    Jun 28, 2019
    Posts:
    138
    I just updated xCode yesterday, but I still have the same issue.
     
  40. Yijiankeji

    Yijiankeji

    Joined:
    Jul 27, 2019
    Posts:
    43
  41. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    Thanks. Requested QA to process it on priority.
     
    nilsdr and luke_avm like this.
  42. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    So your issue now sais 'Closed'. Did you get a response?
     
  43. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    It was closed as duplicate of 1299873
     
  44. luke_avm

    luke_avm

    Joined:
    Mar 26, 2019
    Posts:
    10
    That's true, I reported 1299873 almost a month ago but there was no movement on the issue. 1299873 also did not include an example project for Unity to reproduce the bug.

    I reported 1304394 so that you would have a bare bones project in which you could easily reproduce the error. Have you kept the project to help diagnose the issue?

    Thanks for your help. We're unable to find a work-around for this bug so any guidance would be much appreciated.
     
  45. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    There is one thing you could try. From previous messages I see that you've played with didBecomeInvalidWithError:. The pattern you should observe is that requests do work until this method is called, but not afterwards. The fix would be to recreate the NSURLSession.
     
  46. luke_avm

    luke_avm

    Joined:
    Mar 26, 2019
    Posts:
    10
    Thanks for the suggestion. Would you be able to provide an example of how to do this?

    Since this requires modifying Unity library code, would this only be a temporary fix?

    Also, is there any chance that this bug could be prioritised? It seems that there's quite a few of us with apps out in the wild that are seriously affected by the issue, and have already been impact over the holidays.
     
  47. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    76
    Hi, I also came across this problem, which makes our AR app unusable on iOS 14.2.
    The bug is easy to reproduce when quitting and resuming the app - WebRequest dies every time.
    After 1.5 month after identifying the problem there is still no approved solution on this?
    How should we proceed?
     
  48. halinc

    halinc

    Joined:
    Feb 24, 2019
    Posts:
    32
    we also have the same problem. if there's no unity fix coming soon, it would be very much appreciated if you could give some code sample on how to do this as a temporary workaround!
     
  49. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
  50. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    You wrote there too:
    The expected pattern is:
    - One or more successful requests followed by invalidation
    - After invalidation message all further requests don't work.

    If that isn't the case, then there is something else at play.