Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug IOException : eventcache is being used by another process

Discussion in 'Scripting' started by NicolasVertical, Aug 1, 2023.

  1. NicolasVertical

    NicolasVertical

    Joined:
    Mar 6, 2019
    Posts:
    2
    Hi,

    We have a game in early access on Steam and we are using UnityAnalytics.

    A player has issues and send us the Player.log file, in which we have this error :

    Unable to read event cache file: corrupt
    IOException: The process cannot access the file 'C:\Users\<username>\AppData\LocalLow\<CompanyName>\<GameName>\eventcache' because it is being used by another process.

    Do you know how we can fix this ?

    Unity version : 2021.3.12f1
    The code line involved is just :
    Code (CSharp):
    1.             await Analytics.Initialize();
    2.  
    Here is the stack trace :

    Unable to read event cache file: corrupt

    IOException: The process cannot access the file 'C:\Users\<username>\AppData\LocalLow\CompanyName\GameName\eventcache' because it is being used by another process.
    at [URL='http://system.io/']System.IO[/URL].FileSystem.DeleteFile (System.String fullPath) [0x0001a] in <c9d3ffd4b98649ee9989e1908eaca019>:0
    at [URL='http://system.io/']System.IO[/URL].File.Delete (System.String path) [0x00014] in <c9d3ffd4b98649ee9989e1908eaca019>:0
    at Unity.Services.Analytics.Internal.FileSystemCalls.DeleteFile (System.String path) [0x00000] in <ec4bb24484644e59ad08412540ef0cbb>:0
    at Unity.Services.Analytics.Internal.DiskCache.Clear () [0x00020] in <ec4bb24484644e59ad08412540ef0cbb>:0
    at Unity.Services.Analytics.Internal.DiskCache.Read (System.Collections.Generic.List`1[T] eventEndIndices, System.IO.Stream buffer) [0x000a5] in <ec4bb24484644e59ad08412540ef0cbb>:0
    at Unity.Services.Analytics.Internal.BufferX.LoadFromDisk () [0x00000] in <ec4bb24484644e59ad08412540ef0cbb>:0
    at Ua2CoreInitializeCallback.Initialize (Unity.Services.Core.Internal.CoreRegistry registry) [0x000ef] in <ec4bb24484644e59ad08412540ef0cbb>:0
    at Unity.Services.Core.Internal.CoreRegistryInitializer+<>c__DisplayClass3_0.<InitializeRegistryAsync>g__TryInitializePackageAsync|0 (Unity.Services.Core.Internal.IInitializablePackage package) [0x00083] in <7d85b28f15f14746876359a629bdd631>:0

    Rethrow as AggregateException: One or more errors occurred. (The process cannot access the file 'C:\Users\<username>\AppData\LocalLow\<ComparnyName>\<GameName>\eventcache' because it is being used by another process.)Rethrow as ServicesInitializationException: Some services couldn't be initialized. Look at inner exceptions to get more information.
    at Unity.Services.Core.Internal.CoreRegistryInitializer+<>c__DisplayClass3_0.<InitializeRegistryAsync>g__Fail|2 () [0x00017] in <7d85b28f15f14746876359a629bdd631>:0
    at Unity.Services.Core.Internal.CoreRegistryInitializer.InitializeRegistryAsync () [0x001b3] in <7d85b28f15f14746876359a629bdd631>:0
    at Unity.Services.Core.Internal.UnityServicesInternal+<>c__DisplayClass22_0.<InitializeServicesAsync>g__InitializePackagesAsync|1 () [0x00077] in <7d85b28f15f14746876359a629bdd631>:0
    at Unity.Services.Core.Internal.UnityServicesInternal.InitializeServicesAsync () [0x00141] in <7d85b28f15f14746876359a629bdd631>:0
    at Unity.Services.Core.Internal.UnityServicesInternal.InitializeAsync (Unity.Services.Core.InitializationOptions options) [0x00103] in <7d85b28f15f14746876359a629bdd631>:0
    at Unity.Services.Core.UnityServices.InitializeAsync (Unity.Services.Core.InitializationOptions options) [0x0011b] in <6a2feefaee344e33ba88f8381ca1b475>:0
    at Analytics.Initialize () [0x000a9] in <e9f6a97ce3c04aafb1da4ab3a6f5c734>:0
    at SteamAuthWebService+<>c__DisplayClass1_0.<SteamLogIn>b__0 (SteamLoginResponse response) [0x000b7] in <e9f6a97ce3c04aafb1da4ab3a6f5c734>:0
    at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in <c9d3ffd4b98649ee9989e1908eaca019>:0
    at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00002] in <6f35c1a2b2d34f8b908ede6136862ef9>:0
    at UnityEngine.UnitySynchronizationContext.Exec () [0x00056] in <6f35c1a2b2d34f8b908ede6136862ef9>:0
    at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00014] in <6f35c1a2b2d34f8b908ede6136862ef9>:0
    UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    Sentry.Unity.Integrations.UnityLogHandlerIntegration:LogException(Exception, Object)
    UnityEngine.Logger:LogException(Exception, Object)
    UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    I suppose you did replace "CompanyName" and "GameName" in that string?

    Otherwise I would expect a conflict with another Unity app which also did not change these Player Settings to something unique.

    I can also imagine the user opening the same app multiple times. I know a couple "twitch-finger" users who have a tendency to triple- and sometimes quadruple-click an app icon and just got into the habit of then closing any excess window they had opened rather than changing their double-click behaviour. ;)

    Make sure that Player Setting are set to "disallow multiple instances" (something by that name).
     
  3. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,051
    Something is blocking the analytics cache file, either they have multiple instances of your game running or some security or application is blocking it. I don't think there's much you can do, besides trying to ask them to reboot or to delete the file, and see if the problem still persists.

    The least you can do is to catch the exception that
    Analytics.Initialize()
    is throwing. Then you can either silently disable analytics or show an error message.
     
    MaskedMouse likes this.
  4. NicolasVertical

    NicolasVertical

    Joined:
    Mar 6, 2019
    Posts:
    2
    Thank you for your answers !

    Indeed, I replaced the username, our company name and game name in that string ^^'
    'C:\Users<username>\AppData\LocalLow\CompanyName\GameName\eventcache'


    The player is supposed to launch the game via Steam, I'm going to do some tests to see if I can launch several instances of the game and reproduct the bug on my PC.