mapbox / mapbox-unity-sdk

Mapbox Unity SDK - https://www.mapbox.com/unity/
Other
725 stars 210 forks source link

no 'ETag' header present in response #913

Closed JorgenEngenNapstad closed 6 years ago

JorgenEngenNapstad commented 6 years ago

Getting an error which is crashing the iOS build. Excerpt of the log from xcode below. The "no 'ETag' header present" message is repeated 50+ times before it crashes. Anything I'm missing, or is it a bug?

2018-07-16 17:05:49.256397+0200 abppilot[779:281734] [DYMTLInitPlatform] platform initialization successful
2018-07-16 17:05:49.329501+0200 abppilot[779:281564] -> registered mono modules 0x1062f09a0
-> applicationDidFinishLaunching()
2018-07-16 17:05:49.492734+0200 abppilot[779:281564] Metal GPU Frame Capture Enabled
2018-07-16 17:05:49.493284+0200 abppilot[779:281564] Metal API Validation Disabled
-> applicationDidBecomeActive()
GfxDevice: creating device client; threaded=1
Initializing Metal device caps: Apple A10 GPU
Initialize engine version: 2017.3.1f1 (fc1d3344e6ea)
WARNING: Shader Unsupported: 'Hidden/BlitToDepth' - Pass '' has no vertex shader
WARNING: Shader Unsupported: 'Hidden/BlitToDepth' - Setting to default shader.
WARNING: Shader Unsupported: 'Hidden/BlitToDepth_MSAA' - Pass '' has no vertex shader
WARNING: Shader Unsupported: 'Hidden/BlitToDepth_MSAA' - Setting to default shader.
Setting up 1 worker threads for Enlighten.
  Thread -> id: 16cd93000 -> priority: 1 
UnloadTime: 1.579916 ms
2018-07-16 17:06:19.087728+0200 abppilot[779:282047] Task <D4E9C691-E389-4914-B08E-6352DF519B81>.<0> HTTP load failed (error code: -999 [1:89])
no 'ETag' header present in response for https://api.mapbox.com:443/v4/mapbox.terrain-rgb/12/2073/1190.pngraw?events=true&access_token=pk.####
Stacktrace is not supported on this platform. 
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)

no 'ETag' header present in response for https://api.mapbox.com:443/v4/mapbox.terrain-rgb/12/2074/1190.pngraw?events=true&access_token=pk.####
Stacktrace is not supported on this platform. 
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)

no 'ETag' header present in response for https://api.mapbox.com:443/v4/mapbox.terrain-rgb/12/2075/1190.pngraw?events=true&access_token=pk.####
Stacktrace is not supported on this platform. 
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
wilhelmberg commented 6 years ago

Hm, not sure if no 'ETag' header present in response is the reason for the crash as this is just a warning and not an error and shouldn't do any harm.

I suspect another (iOS/Unity) problem surfaces via the ETag warning. Because when I check one of the above error URLs in the browser, eg https://api.mapbox.com:443/v4/mapbox.terrain-rgb/12/2073/1190.pngraw?events=true&access_token=pk.####, the response does have an ETag.

@JorgenEngenNapstad

  1. do you see any tiles before the app crashes?
  2. we've seen weird, non-reproducible and intermittent errors on certain Unity/iOS combinations for tile loading: 2.1. any chance you can try different versions of Unity and iOS? 2.2. also try setting environment variable CFNETWORK_DIAGNOSTICS in XCODE to 3. That should give you more low level information about the requests - and the reason of their failure.
JorgenEngenNapstad commented 6 years ago
  1. Yes, we get tiles. Some times it crashes fast (eg. almost immediately after opening the app) and some times we can pan and zoom around loading several tiles before it crashes.

2.1 We can try using a newer version of Unity. What do you mean with different version of iOS? We are getting the error on several devices running different iOS versions (all of them above 10).

2.2 Will try this first and see if we get an error message giving us a better idea of whats happening.

wilhelmberg commented 6 years ago
  1. Yes, we get tiles. Some times it crashes fast (eg. almost immediately after opening the app) and some times we can pan and zoom around loading several tiles before it crashes.

hm, maybe the crashes are not web request related then. The problems we saw were always from first request on.

You could try to attach TileErrorHandler.cs to your map object and check if you get more information related to tile loading.

2.1 We can try using a newer version of Unity. What do you mean with different version of iOS? We are getting the error on several devices running different iOS versions (all of them above 10).

Unfortunately I don't remember the exact version numbers neither for Unity nor for iOS but we saw apps crash on simple web requests for no apparent reason on some devices - other devices with different iOS worked. Switching to another Unity version crashes disappeared on all devices.

JorgenEngenNapstad commented 6 years ago

Changing the build settings from Always use latest 2017.3 to Always use latest 2017.x in Unity Cloud Build seems to have solved it actually. Haven't had time to debug it any more. Would be interesting to figure out what happened though.

jeffries7 commented 5 years ago

This issue has popped up for me now.

We're using a Unity 2018.3.0b9 and we've just upgraded the project to 2018.3.0f1

On the older beta version of Unity everything was fine then one day iOS builds began crashing with the same issue as above, a constant feed of no response which causes the app to crash. We upgraded the version of Unity but the issue still persists. Initially we were using a custom map style but i've tried going back to a default map style but to no avail.

The app we're using is processing other web requests at the same time, but this didn't change between having a working version and a broken version.

anthodb commented 5 years ago

Same issue here on Unity 2018.2.19f1. App is not crashing but throwing warnings on production: Does someone have an idea to fix this?

no \'ETag\' header present in response for https://api.mapbox.com:443/v4/xxxxxxxxxx?events=true&access_token=xxxxxxxxxx : _Mapbox.Platform.Cache.cAnonStorey1:<>m0(Response) Mapbox.Unity.Utilities.c_Iterator0:MoveNext() Mapbox.Unity.Utilities.Routine:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

wilhelmberg commented 5 years ago

@jeffries7 @anthodb

no 'ETag' header present is just a warning https://github.com/mapbox/mapbox-unity-sdk/blob/66b9056b25684f91c0aaf18223c5ce5444eb7646/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Platform/Cache/CachingWebFileSource.cs#L241 but might hint that something else is wrong with regards to networking:

Please take a look at my comment and other comment above (just before yours) and see if you can get more information using the suggestions supplied there.

anthodb commented 5 years ago

Thanks a lot for your answer! I'll try to just remove this warning inside the plugin or using reflexion. I'll keep this updated if I find a workaround.

jeffries7 commented 5 years ago

I found the cause of my issue. I was trying to load to many tiles when loading the app, this wasn't an issue on Samsung devices but we noticed crashes on other android devices and on all iOS devices. I've since limited how many tiles can be loaded within a certain period of time.

For exmaple if I try and load 7x7 around the player on an iPhone XR then it crashes, although we're also processing other web calls so this could also be contributing.

ask-a-lie commented 5 years ago

@BergWerkGIS

I found out why "no 'ETag' header present" warning is happened. In iOS, response header has "Etag" key, not "ETag", so mapbox-sdk cannot find "ETag" header key.

You can find this by logging headerKey in WWWConnection.mm (which is generated by Unity) like below.

// In (void)handleResponse:(NSURLResponse*)response method
for (id headerKey = [headerEnum nextObject]; headerKey; headerKey = [headerEnum nextObject]) {
    NSLog(@"%@", headerKey);
    UnityReportWWWResponseHeader(self.udata, [headerKey UTF8String], [[respHeader objectForKey: headerKey] UTF8String]);
}

My environment:

FYI: In allHeaderFields method, the characters of header keys are automatically changed like ETag -> Etag.

https://developer.apple.com/documentation/foundation/nshttpurlresponse/1417930-allheaderfields?language=objc

yosun commented 4 years ago

what's the fix

vinnievivace commented 4 years ago

Bumping this as I am also receiving multiple ETag warnings in iOS Builds:

"no 'ETag' header present in response for https://api.mapbox.com:443/v4/mapbox.satellite"

whilst its true they are "only warnings", they are followed by this exception

"System.Collections.Generic.Dictionary2[TKey,TValue].get_Item (TKey key) (at <00000000000000000000000000000000>:0) Mapbox.Platform.Cache.CachingWebFileSource+<>c__DisplayClass12_0.<Request>b__0 (Mapbox.Platform.Response headerOnly) (at <00000000000000000000000000000000>:0) System.Action1[T].Invoke (T obj) (at <00000000000000000000000000000000>:0) Mapbox.Unity.Utilities.HTTPRequest+d__12.MoveNext () (at <00000000000000000000000000000000>:0) Mapbox.Unity.Utilities.Runnable+Routine.MoveNext () (at <00000000000000000000000000000000>:0) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <00000000000000000000000000000000>:0)"

@BergWerkGIS if the above information in @ask-a-lie post is correct, can that not be hot fixed by Mapbox?

thanks guys.

highpockets commented 3 years ago

I have the same issue. When running the app for the first time on a device, this happens always and the map does not initialize and when it fails after 20 seconds or so I have it setup to reload the scene by pressing a button and retrying/reloading works almost instantly but it is a really bad user experience to have to wait 30 seconds before entering the app.

EDIT: My issue with the scene not loading the first time a user enters the app seems to be actually connected with loading the said scene async as an Additive scene.. I don't know why this happens, but when I load the scene additively the Etag warnings appear, when I load it as a Single scene, I instead get the Dictionary exceptions as @vinnievivace mentions above.

chainmaster99 commented 3 years ago

I have same issue when running mobile app first time on a device. How can I fix this?

bPavenko commented 8 months ago

I have success. You just should find CachingWebFileSource.cs in Unity project and make veriant for ETag, like this:

image