Giter Site home page Giter Site logo

Comments (10)

wilhelmberg avatar wilhelmberg commented on August 15, 2024

Commenting validation and hard coding the token works:
image

Although there seem to be other problems too as buildings and their styles are still missing.

EDIT
After commenting ValidateMapboxAccessFile() and hard coding the token the rest works as expected:

image

from mapbox-unity-sdk.

david-rhodes avatar david-rhodes commented on August 15, 2024

@BergWerkGIS Yeah, since I don't have Android I was unable to test myself. I thought that @MateoV had tested to ensure everything was working as expected, though.

The actual loading of the text file is done with WWW, but as you mentioned ValidateMapboxAccessFile fails because the "file is not found" on Android. I think we should just #if !UNITY_ANDROID the contents of this method and do some extra error checking in IEnumerator LoadMapboxAccess().

from mapbox-unity-sdk.

david-rhodes avatar david-rhodes commented on August 15, 2024

@BergWerkGIS do you know if the directory is not able to be found, or if the file does not exist?

if (!Directory.Exists(Application.streamingAssetsPath) || !File.Exists(_accessPath)) {
    throw new InvalidTokenException("Please configure your access token in the menu!");
}

from mapbox-unity-sdk.

david-rhodes avatar david-rhodes commented on August 15, 2024

Regarding Problem 2, we may have to hold a queue of requests until the async read is done, then fire them off. This seems like a simple fix, but I won't be able to test. Do you have a better idea?

from mapbox-unity-sdk.

wilhelmberg avatar wilhelmberg commented on August 15, 2024

do you know if the directory is not able to be found, or if the file does not exist?

I think Directory.Exists() and File.Exists() don't work with the url that points into the jar file.

Regarding Problem 2, we may have to hold a queue of requests until the async read is done, then fire them off. This seems like a simple fix, but I won't be able to test. Do you have a better idea?

I would prefer to somehow make loading of the token sync.
Otherwise all code that requests anything would have to check and wait till the token is available.

Will have a look tomorrow.

How about not using IEnumerator and yield but something like:

void LoadMapboxAccess() {
    var request = new WWW(_accessPath);
    while (!request.isDone) { Thread.Sleep(10); }
    AccessToken = request.text;
}

from mapbox-unity-sdk.

david-rhodes avatar david-rhodes commented on August 15, 2024

How about not using IEnumerator and yield?

I never thought to use WWW like that, but should be possible. We would have to include a timeout or error handling to prevent freezing the entire application. Android is so fragmented, you never know what device or OS this will not work for 😏.

from mapbox-unity-sdk.

isiyu avatar isiyu commented on August 15, 2024

@david-rhodes and I tried a couple of solutions wanted to get your thoughts on these (sorry the diffs aren't super helpful here) Tested on and Android device and the styles and buildings demo loads. https://mapbox.slack.com/files/isiyu/F53553D55/image_uploaded_from_ios.mp4

@BergWerkGIS wanted to get your thoughts on which solution to go with for now

option A: cache requests 3ffc117

What the logs look like for a successful run, with a valid token:

option B: thread sleep 5125bce

with no token:
optionb_notoken
optionb_notoken

from mapbox-unity-sdk.

david-rhodes avatar david-rhodes commented on August 15, 2024

For clarity, Option B works. Please note: #if !_UNITY_ANDROID should be #if !UNITY_ANDROID. Testing without a token was just to see what exception was thrown. The correct InvalidTokenException was thrown. 👍

@BergWerkGIS this was your suggestion, and it seems to work as intended. Any idea why your implementation did not work earlier today? In any case, we would probably want to implement a timeout for the while loop and throw an exception in the event the WWW never finishes.

As mentioned in slack, Option A is likely "safer," but it is less efficient and does not currently allow cached requests to be cancelled (but this is seriously an edge case). We can fix this, but I'd like to know your thoughts, first.

from mapbox-unity-sdk.

wilhelmberg avatar wilhelmberg commented on August 15, 2024

@BergWerkGIS this was your suggestion, and it seems to work as intended. Any idea why your implementation did not work earlier today?

No idea, maybe some error I missed during deploy and an old version was used on the device.
Works today. 🎉

I'd like to know your thoughts, first.

I'd prefer Option B to caching at that level.


My PR for MapboxAccess.cs, including:

  • Android fix
  • timeout for LoadMapboxAccess()
  • UWP support
  • ServerCertificateValidationCallback to make HttpWebRequest on Mono work with HTTPS requests

from mapbox-unity-sdk.

david-rhodes avatar david-rhodes commented on August 15, 2024

Fixed: #26

from mapbox-unity-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.