Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Invalidating cached asset on Unity Accelerator

Discussion in 'Unity Accelerator' started by alexvector, Mar 9, 2020.

  1. alexvector

    alexvector

    Joined:
    Oct 9, 2019
    Posts:
    9
    Hello.

    Is it possible to replace/invalidate the cached version of an asset?

    This is our issue:

    There is probably a bug somewhere (probably not related the Accelerator) that caused one of our prefab to be imported with some of its references as null. However when we open that prefab the data is ok and if we do a "Reimport" it turns back to normal.

    What makes the prefab bug worse, is that this invalid prefab seems to have been stored in the Accelerator. Now everyone that opens the Unity project will get the invalid prefab import. If I open the project without the accelerator, the prefab is imported correctly.

    So I was wondering if there was a way to update/clear the cache for that particular prefab. Note that I do not want to clear the entire cache as it takes many hours to rebuild.

    One workaround for the moment is to modify that prefab slightly (like slightly changing a value somewhere) this seems to create a new "version" of the asset in the cache and that one works ok. But if we ever go back to the previous values we get the error again.

    Thanks
     
  2. bradunity

    bradunity

    Unity Technologies

    Joined:
    Nov 12, 2013
    Posts:
    149
    Yes, @alexvector, it is possible to remove any items in the Accelerator, though it's not an easy process (yet). Here's what you'll want to do:
    1. When you go back to the original settings for your asset and reimport it, you should find a log that looks something like the following in your Editor.log:
    2. With the above information, you can use the Accelerator's tooling to have that artifact removed from its cache by executing something like this:
      Code (Csharp):
      1. unity-accelerator tool delete 192.168.0.114:10080 78b2fdc254b0a4f8a4693a81bb96598a 7bd4d20d898b2064c9ce47b5073e92f3
    3. Now, you should be able establish all the correct settings for your asset and reimport it which should populate the Accelerator's cache with the artifact you want preserved.
     
    alexvector likes this.
  3. alexvector

    alexvector

    Joined:
    Oct 9, 2019
    Posts:
    9
    Thanks for the help. That delete command worked and it fixed the issue for that prefab for now.

    I think I know what happened, but it raised another issue.

    We have two Unity projects (a client and a server) that share some assets using symlinks. The client and the server share the same scrips, but with different Define Symbols in the project. A MonoBehavior has some of the code inside a #ifdef SERVER where some of the serialized fields are defined (not an ideal design, but it is what we have at the moment). If that prefab happened to be first loaded and cached by the server project, it would cache an "incorrect" version.

    We use the command line to enable the cache so I tried to add "-cacheServerNamespacePrefix GameServer" to the command line (as documented here https://forum.unity.com/threads/usage-in-batchmode.819543/) but it does not appear to work. The namespace hash in the log appears the same, whatever the prefix I set, and it still downloads assets where I would expect it to upload a new version of it for the new namespace.

    Am I understanding the use of cacheServerNamespacePrefix correctly?

    I tried "-cacheServerEnableUpload false". This one appears to work but I would rather use the namespace prefix if possible.

    Thanks again,
    Alex
     
  4. alexvector

    alexvector

    Joined:
    Oct 9, 2019
    Posts:
    9
    A bit more info:

    When I setup the cache server in the Project Settings and set a Namespace Prefix there, it works as expected. However when I set it through the cacheServerNamespacePrefix command line, it has no effect.
     
    bradunity likes this.
  5. bradunity

    bradunity

    Unity Technologies

    Joined:
    Nov 12, 2013
    Posts:
    149
    You found a bug, @alexvector. Sure enough, in 2019.3 our logic only uses the value set in the Project Settings. The command line option is effectively ignored. I suspect it's not helpful for your case, but it has been fixed in 2020.1 and that team is evaluating if it can be backported to 2019.3 (or possibly for the 2019 LTS release).
     
    alexvector likes this.
  6. alexvector

    alexvector

    Joined:
    Oct 9, 2019
    Posts:
    9
    Thanks for the info. It would be nice if it is back-ported to 2019.3 since we don't plan on moving to 2020 anytime soon. But in the mean time I "unshared" the EditorSettings for the game server project to set the prefix manually.
     
unityunity