Skip to content

Editor: Skip CesiumIonSession.Tick() when Unity is offline #575

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Heisenberk-Karabay
Copy link

Problem

If the Unity Editor launches without an Internet connection, CesiumIonServerManager.instance.currentSession.Tick() throws every frame because the DNS lookup for https://api.cesium.com fails. The result is an endless stream of red-error messages:

Exception: Request for `https://api.cesium.com/appData` failed:
Cannot resolve destination host
Exception: Failed to obtain _appData, can't resume connection

The spam clutters the Console and can even interrupt later domain reloads.

Change

Added a single guard clause at the top of
Editor/CesiumEditorUtility.UpdateIonSession():

if (Application.internetReachability == NetworkReachability.NotReachable)
    return;

When Unity reports that the machine is offline the function now returns immediately, so the session is ticked again only after connectivity is restored.

Problem
-------
If the Unity Editor launches without an Internet connection,
CesiumIonServerManager.instance.currentSession.Tick() throws every
frame because the DNS lookup for https://api.cesium.com fails.  
The result is an endless stream of red-error messages:

    Exception: Request for `https://api.cesium.com/appData` failed:
    Cannot resolve destination host
    Exception: Failed to obtain _appData, can't resume connection

The spam clutters the Console and can even interrupt later domain
reloads.

Change
------
Added a single guard clause at the top of
Editor/CesiumEditorUtility.UpdateIonSession():

    if (Application.internetReachability == NetworkReachability.NotReachable)
        return;

When Unity reports that the machine is offline the function now returns
immediately, so the session is ticked again only after connectivity is
restored.
@j9liu
Copy link
Contributor

j9liu commented May 19, 2025

Thanks for the PR @Heisenberk-Karabay! Could you please sign a Contributor License Agreement (CLA) for us? We need this before we can take a look at your PR's contents. Thanks!

@Heisenberk-Karabay
Copy link
Author

Hello, signed it.

Copy link
Contributor

@j9liu j9liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @Heisenberk-Karabay!

I confirmed that this prevents the Failed to connect... logs from appearing in the Console, though it does not enable the tileset to appear in Play Mode. Is that expected for this PR?

I'm also not sure if the Application.internetReachability check is sufficient for all offline scenarios. The Unity docs say:

Do not use this property to determine the actual connectivity. For example, the device can be connected to a hot spot, but not have the actual route to the network.

Still, the check is an improvement overall, and is something that we should consider putting in the Editor code anyway.

@Heisenberk-Karabay
Copy link
Author

No, that is not the intended behavior. The PR allowed me to see the tileset in Play mode. I’ll try to reproduce the issue with a fresh install. I’ll also look into the matter regarding Application.internetReachability. I’m going to investigate this ASAP and make the necessary changes. I can either submit them as a separate PR or include them in this one—whichever you prefer.

@j9liu
Copy link
Contributor

j9liu commented May 27, 2025

@Heisenberk-Karabay Feel free to keep things going on this PR! Thanks for the quick response 🙏

@Heisenberk-Karabay
Copy link
Author

Hello, I’ve tested it and recorded a video of the process. The tileset loads completely offline without any errors. I also included the Windows taskbar in the recording to confirm that there was no internet connection.

PR.575_test.mp4

@Heisenberk-Karabay
Copy link
Author

Updated the code to do network checks as referenced in: https://docs.unity3d.com/6000.1/Documentation/ScriptReference/NetworkReachability.html
If there's anything missing, please don't hesitate to let me know.

@j9liu
Copy link
Contributor

j9liu commented May 28, 2025

Sorry for the mistake @Heisenberk-Karabay, it turned out to be something on my side while testing. Thanks for incorporating the feedback!

Can I trouble you to update CHANGES.md for this fix? Once the changelog has been updated, I'm happy to merge.

@Heisenberk-Karabay
Copy link
Author

No worries. I'm not sure which part of the CHANGES.md file I should update — should I write it under v1.16.0 - 2025-05-01, or will there be a new version where I should document the changes instead?

@j9liu
Copy link
Contributor

j9liu commented May 28, 2025

@Heisenberk-Karabay you can put it under a new version! We usually just leave it as ? - ? until we make the final release.

Also, sorry to double-back -- but a colleague just pointed out to me that we need to test this out with Cesium ion self-hosted (which is supposed to work on self-contained / offline networks). I need to hold off on the merge until we try this out 😬

@Heisenberk-Karabay
Copy link
Author

No problem at all! I'll be eagerly waiting for the results of the tests. In the meantime, I'll go ahead and update the CHANGES.md file. Hope everything goes smoothly on your end!

@Heisenberk-Karabay
Copy link
Author

I've updated the CHANGES.md file—please let me know if anything looks off or needs to be adjusted.

@kring
Copy link
Member

kring commented May 30, 2025

@j9liu how are you testing this? I tried it out by putting my system in airplane mode shortly after launching Unity (I can't do it beforehand, because then I won't be able to check out the network license). When I do this, I do see the two errors in the top post, but each is only reported once. It's not clear to me what would cause those messages to be spammed repeatedly.

@Heisenberk-Karabay
Copy link
Author

I think the issue was on my side—I reported it a bit inaccurately. The error messages only show up once.

@j9liu
Copy link
Contributor

j9liu commented May 30, 2025

@j9liu how are you testing this? I tried it out by putting my system in airplane mode shortly after launching Unity (I can't do it beforehand, because then I won't be able to check out the network license).

I tested this in the same way -- once I see Unity start up after it's verified our licenses, I disconnect myself from the internet. However, I was only seeing the _appData error once on my side too.

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

Successfully merging this pull request may close these issues.

3 participants