Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
125 stars 2 forks source link

Radiant Dash Reinitializes Every Single Time When Launching Game, Causes Cloud Storage Pileup #2468

Open yoshiyoshyosh opened 3 weeks ago

yoshiyoshyosh commented 3 weeks ago

Describe the bug?

When launching the game, I've been noticing that my cloud storage increases by ~300KB every single time. Even if I don't do anything, send any messages, get sent and messages, save items, whatever, it still happens. This is, of course, annoying, because it represents a slow time bomb to my storage being full.

In order to get to the bottom of what could possibly be taking up this space, I requested a usage report. I found hundreds of TopBar and Screens objects filling the usage report, each one increasing ever so slightly--tens of KB--as it went on. I requested another usage report between a few relaunches, and diff'd what could possibly be different about the two. Sure enough, the only different items were the TopBar and Screens objects (also, every record had its record ID shuffled? even inventory objects? is that normal? could that be the underlying reason? you'll see why I'm asking this question later)

Looking at my logs, I suspiciously noticed some lines saying

20:00:55.390 ( 62 FPS)  Loading target workspace Private/RadiantDash/Screens for U-yosh
20:00:55.390 ( 62 FPS)  Loading workspace Private/RadiantDash/Screens from: resrec:///U-yosh/Workspaces/Private/RadiantDash/Screens for U-yosh
20:00:55.390 ( 62 FPS)  Loading target workspace Private/RadiantDash/TopBar for U-yosh
20:00:55.390 ( 62 FPS)  Loading workspace Private/RadiantDash/TopBar from: resrec:///U-yosh/Workspaces/Private/RadiantDash/TopBar for U-yosh
...
20:00:56.241 ( 45 FPS)  Workspace Private/FacetAnchors/RightForearmBottom/Default initialized to default
20:00:56.321 ( 45 FPS)  Workspace Private/RadiantDash/Screens initialized to default
20:00:56.376 ( 45 FPS)  Workspace Private/FacetAnchors/LeftHandBottom/Default initialized to default
20:00:56.377 ( 45 FPS)  Workspace Private/RadiantDash/TopBar initialized to default
20:00:56.378 ( 45 FPS)  Workspace Private/FacetAnchors/ViewBottom/Default initialized to default
20:00:56.379 ( 45 FPS)  Workspace Private/FacetAnchors/LeftForearmBottom/Default initialized to default
20:00:56.380 ( 45 FPS)  Workspace Private/FacetAnchors/ViewFront/Default initialized to default

Searching for the log lines in the code, I was led to the LoadTargetWorkspace() function in FrooxEngine.Workspace (culled a bit for brevity's sake):

Uri workspaceRecordUri = GetWorkspaceRecordUri(workspace, userId);
if (workspaceRecordUri != null) {
    UniLog.Log($"Loading workspace {workspace} from: {workspaceRecordUri} for {userId}");
    record = (await base.Engine.RecordManager.FetchRecord(workspaceRecordUri))?.Entity;
    if (!LocalForceReinitialize && Uri.TryCreate(record?.AssetURI, UriKind.Absolute, out var assetUri)) {
        string text = await base.Engine.AssetManager.GatherAssetFile(assetUri, 100f);
        UniLog.Log("Loading workspace asset file: " + text);
        if (File.Exists(text)) {
            try {
                data = DataTreeConverter.Load(text, assetUri);
            }
            ...
        }
    }
}
await default(ToWorld);
if (data != null) {
    ...
    UniLog.Log("Loaded workspace " + workspace + " for " + userId);
    ...
}
else if (_currentDefault == null || !(_currentDefault == InitializeWorkspace.Target)) {
    ...
    UniLog.Log("Workspace " + workspace + " initialized to default");
    ...
}

It appears that the if (!LocalForceReinitialize && Uri.TryCreate(record?.AssetURI, UriKind.Absolute, out var assetUri)) isn't evaluating to true, given how that Loading workspace asset file: log message isn't showing. LocalForceReinitialize is only set to True when -ResetDash is given as a launch param, which, well, I'm not doing, given how I'm not getting a Resetting Dash! log line. As such, the only conceivable notion is that Uri.TryCreate() is failing for some reason. Why? I don't know.

To Reproduce

Annoyingly, though, I haven't been found anyone having the same problem, and thus I'm not sure if this will be reproduced by anyone. Is it a linux only bug? Not sure. Will see if anyone there can reproduce it.

Expected behavior

The game is able to recognize my existing RadiantDash and TopBar assets, not allowing

Additionally, if the game culled every workspace that isn't the current one whenever initializing the workspace to default, this would function both as a workaround to this issue and not also be an issue for someone who -ResetDash, not knowing where a random extra 300KB of stuff came from.

Screenshots

Notice how the Syncing 3 items appears every time.

https://github.com/Yellow-Dog-Man/Resonite-Issues/assets/36683489/b1cae756-f50f-4cf6-840b-ea9ae301557f

Resonite Version Number

2024.6.25.1149

What Platforms does this occur on?

Linux

What headset if any do you use?

No response

Log Files

these are two log files taken from the launches in the above video

https://gist.github.com/yoshiyoshyosh/c48b29feff02b3a14f2edda0bb77788c https://gist.github.com/yoshiyoshyosh/0d20398e3d01b03db4462ff4119358d8

Additional Context

No response

Reporters

yosh

stiefeljackal commented 3 weeks ago

Based on what I saw in the logs and the usage report, I believe the engine is failing to fetch the record for "Top Bar" and "Screens" as I am seeing multiple records for them. This would explain why the space continuously grows and why the "Top Bar" and "Screens" records keep syncing back (the third record is always R-SettingsData). Looking at the decompiled code snippit, I assume record is null due to the fetching failure. If possible, see if you can monitor your network traffic (mitmproxy or similar) to capture the HTTP request and response for those records.

On another note, -ResetDash does not create a new record; it utilizes the same record id used for the "Top Bar" and "Screens" records. The difference is that it does not load the corresponding brson file and allows the default "Top Bar" and "Screens" to load. The engine marks those as modified afterwards, which causes those records to be forcefully resynced back with entirely different brson files.

coolymike commented 3 weeks ago

This could have a similar cause as the issue I commented about in https://github.com/yellow-dog-man/brotli.net/issues/3#issuecomment-2188664090. Essentially, the Dash does not save on the Linux Native version. If the Dash is modified and saved on the Windows version (either on Windows, or under Proton), the modified Dash loads fine on the Linux native version. If the Dash is saved on the Linux native version, it resets on restart . The logs I get appear very similar to those in the post here.

Note that in order to get anything to sync at all, I'm running a patched Brotli.NET.

shiftyscales commented 2 weeks ago

This issue sounds like it could potentially have some relation with #594.

shiftyscales commented 2 weeks ago

Seeking input from @Frooxius.