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

Problem clearing cache at runtime #1931

Open
lukeholmes1986 opened this issue Jan 1, 2025 · 1 comment
Open

Problem clearing cache at runtime #1931

lukeholmes1986 opened this issue Jan 1, 2025 · 1 comment

Comments

@lukeholmes1986
Copy link

lukeholmes1986 commented Jan 1, 2025

Followed the post #212 here to add the clear cache function which works fine on the landing scene however as we then move into the following scene the api throws this null ref, has there been a change in the ordering of events the SDK does since that original post preventing me from doing this at run time? Thanks

error getting tile mapbox://styles/XXXXX-XXXXXXX/xxxxxxxxxxxxx2 from cache
System.NullReferenceException: Object reference not set to an instance of an object
  at Mapbox.Platform.Cache.SQLiteCache.getTilesetId (System.String tilesetName) [0x0000d] in C:\Users\XXX\XXX- XXX- DEV\Assets\Mapbox\Core\mapbox-sdk-cs\Platform\Cache\SQLiteCache\SQLiteCache.cs:409 
  at Mapbox.Platform.Cache.SQLiteCache.Get (System.String tilesetName, Mapbox.Map.CanonicalTileId tileId) [0x0000f] in C:\Users\xxxx\xxxx - XXX- DEV\Assets\Mapbox\Core\mapbox-sdk-cs\Platform\Cache\SQLiteCache\SQLiteCache.cs:318 
UnityEngine.Debug:LogErrorFormat (string,object[])
Mapbox.Platform.Cache.SQLiteCache:Get (string,Mapbox.Map.CanonicalTileId) (at Assets/Mapbox/Core/mapbox-sdk-cs/Platform/Cache/SQLiteCache/SQLiteCache.cs:336)
Mapbox.Platform.Cache.CachingWebFileSource:Request (string,System.Action`1<Mapbox.Platform.Response>,int,Mapbox.Map.CanonicalTileId,string) (at Assets/Mapbox/Core/mapbox-sdk-cs/Platform/Cache/CachingWebFileSource.cs:132)
Mapbox.Unity.MapboxAccess:Request (string,System.Action`1<Mapbox.Platform.Response>,int,Mapbox.Map.CanonicalTileId,string) (at Assets/Mapbox/Unity/MapboxAccess.cs:243)
Mapbox.Map.Tile:Initialize (Mapbox.Platform.IFileSource,Mapbox.Map.CanonicalTileId,string,System.Action) (at Assets/Mapbox/Core/mapbox-sdk-cs/Map/Tile.cs:144)
ImageDataFetcher:FetchData (DataFetcherParameters) (at Assets/Mapbox/Unity/MeshGeneration/Factories/ImageDataFetcher.cs:35)
Mapbox.Unity.MeshGeneration.Factories.MapImageFactory:OnRegistered (Mapbox.Unity.MeshGeneration.Data.UnityTile) (at Assets/Mapbox/Unity/MeshGeneration/Factories/MapImageFactory.cs:127)
Mapbox.Unity.MeshGeneration.Factories.AbstractTileFactory:Register (Mapbox.Unity.MeshGeneration.Data.UnityTile) (at Assets/Mapbox/Unity/MeshGeneration/Factories/AbstractTileFactory.cs:71)
Mapbox.Unity.Map.AbstractMapVisualizer:LoadTile (Mapbox.Map.UnwrappedTileId) (at Assets/Mapbox/Unity/Map/AbstractMapVisualizer.cs:266)
Mapbox.Unity.Map.AbstractMap:TileProvider_OnTileAdded (Mapbox.Map.UnwrappedTileId) (at Assets/Mapbox/Unity/Map/AbstractMap.cs:675)
Mapbox.Unity.Map.AbstractMap:TriggerTileRedrawForExtent (Mapbox.Unity.Map.TileProviders.ExtentArgs) (at Assets/Mapbox/Unity/Map/AbstractMap.cs:954)
Mapbox.Unity.Map.AbstractMap:OnMapExtentChanged (object,Mapbox.Unity.Map.TileProviders.ExtentArgs) (at Assets/Mapbox/Unity/Map/AbstractMap.cs:961)
Mapbox.Unity.Map.TileProviders.AbstractTileProvider:OnExtentChanged () (at Assets/Mapbox/Unity/Map/TileProviders/AbstractTileProvider.cs:41)
Mapbox.Unity.Map.TileProviders.QuadTreeTileProvider:UpdateTileExtent () (at Assets/Mapbox/Unity/Map/TileProviders/QuadTreeTileProvider.cs:67)
Mapbox.Unity.Map.AbstractMap:InitializeMap (Mapbox.Unity.Map.MapOptions) (at Assets/Mapbox/Unity/Map/AbstractMap.cs:793)
Mapbox.Unity.Map.AbstractMap:SetUpMap () (at Assets/Mapbox/Unity/Map/AbstractMap.cs:670)
Mapbox.Unity.Map.AbstractMap:Initialize (Mapbox.Utils.Vector2d,int) (at Assets/Mapbox/Unity/Map/AbstractMap.cs:341)
Mapbox.Unity.Map.InitializeMapWithLocationProvider:LocationProvider_OnLocationUpdated (Mapbox.Unity.Location.Location) (at Assets/Mapbox/Unity/Map/InitializeMapWithLocationProvider.cs:30)
Mapbox.Unity.Location.AbstractLocationProvider:SendLocation (Mapbox.Unity.Location.Location) (at Assets/Mapbox/Unity/Location/AbstractLocationProvider.cs:26)
Mapbox.Unity.Location.AbstractEditorLocationProvider/<QueryLocation>d__6:MoveNext () (at Assets/Mapbox/Unity/Location/AbstractEditorLocationProvider.cs:40)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)

Unity version: 2022.3.43f1
Models of phones tested: Pixel 6
Android Version 13
Scripting Backend: Mono
Api Compatibility Level: 34
Mapbox SDK version: Mapbox 2.1.1
The platform you're building to: Android
A description of what you're trying to do: Error clearing the style cache on app launch

@lukeholmes1986
Copy link
Author

Any help would be really appreciated just to be very clear i can put the below in a logout style fuction which correctly wipes the cache but if i try to attempt this the other way around and clear before we first open the "world" scene that relies on mapbox data I see the above error. Is there a safe way to achieve this ?

public void ClearCache()
{
CachingWebFileSource cwfs = _fileSource as CachingWebFileSource;
if (null != cwfs)
{
cwfs.Clear();
}
}

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

1 participant