CollapseLauncher / Collapse

An Advanced Launcher for miHoYo/HoYoverse Games
MIT License
1.41k stars 65 forks source link

[Bug]: Crash when loading "Game Settings" page before initial game launch #364

Closed Kiki79250CoC closed 10 months ago

Kiki79250CoC commented 10 months ago

Affected Version

Collapse 1.72.14

Bug Behavior

I installed GI and was ready to launch, but before do the initial launch I tried to open the Game Settings page to try tweak some things and Collapse just preferred to close.

Expected Behavior

An error that's telling me this isn't possible, that I have to do the initial game launch before accessing this page.

Steps to reproduce

  1. Install a game (in my case it was GI)
  2. Before trying to launch it, go to the "Game Settings page"
  3. Collapse has quit.

Related Issues

No response

Screenshot(s)

No response

Additional Information

I mention Genshin but maybe the other games are affected by this behavior, can't really test for HSR and HI3 as both were already launched once (or 500 times for HSR and 4 for HI3) when I noticed this bug.

Nevertheless, I think this crash happened because it was trying to reach registry values to set up the page before display it to me, but as they weren't created yet, Collapse didn't liked that and just crashed.

I tried to open the dump file myself using my Visual Studio 2022 environment, and the only thing I found is the Exception code: 0xc000027b (which isn't really relevant as Google only refers this error for the MS Store) I think I have to use more advanced tools to find a better explanation of the bug do that, so I give you the dump files (I tried twice to be sure this wasn't just an isolated (out of luck) case)

CollapseLauncher.exe.2040.dmp CollapseLauncher.exe.4244.dmp


Tested on my Windows 11 (22H2, delta .2861) laptop only. Can't tested on another device like my desktop PC as it is running Windows 7 SP1 ESU, which is obviously incompatible with Collapse.

bagusnl commented 10 months ago

Heyyo~ Thanks for bringing the issue up to us. This is caused by how the GSP module load and parse the registry value. Since on the new installation, the registry is still empty, GSP frontend will crash because the value is nulled for both of these.

https://github.com/CollapseLauncher/Collapse/blob/0b643611baa8310dae5f9a7f96efb3866f8e682e/CollapseLauncher/Classes/GameManagement/GameSettings/Genshin/RegistryClass/GeneralData.cs#L347-L348

Many attempts to fix this to no avail and it always come back. We might just gonna give the graphicsData and globalPerfData a default value when its nulled. What do you think @shatyuka ?

shatyuka commented 10 months ago

I think it can't be null.

https://github.com/CollapseLauncher/Collapse/blob/0b643611baa8310dae5f9a7f96efb3866f8e682e/CollapseLauncher/Classes/GameManagement/GameSettings/Genshin/RegistryClass/GraphicsData.cs#L18-L21

bagusnl commented 10 months ago

yeah, I think we must provide some valid fallback value. The ideal value should be the default but it can be something like this

// Fields
private readonly string _graphicsDataFallback = ""{\"currentVolatielGrade\":-1,\"customVolatileGrades\":[{\"key\":1,\"value\":2},{\"key\":2,\"value\":1},{\"key\":3,\"value\":2},{\"key\":4,\"value\":3},{\"key\":5,\"value\":2},{\"key\":6,\"value\":3},{\"key\":7,\"value\":1},{\"key\":8,\"value\":3},{\"key\":9,\"value\":1},{\"key\":10,\"value\":2},{\"key\":11,\"value\":1},{\"key\":12,\"value\":2},{\"key\":13,\"value\":2},{\"key\":16,\"value\":3},{\"key\":15,\"value\":1},{\"key\":17,\"value\":1},{\"key\":19,\"value\":1}],\"volatileVersion\":\"OSRELWin3.8.0\"}";

private readonly string _globalPerfDataFallback = "{\"saveItems\":[{\"entryType\":1,\"index\":1,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":2,\"index\":0,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":3,\"index\":1,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":4,\"index\":2,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":5,\"index\":1,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":6,\"index\":2,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":7,\"index\":0,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":8,\"index\":2,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":9,\"index\":0,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":10,\"index\":1,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":11,\"index\":0,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":12,\"index\":1,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":13,\"index\":1,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":16,\"index\":2,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":15,\"index\":0,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":17,\"index\":0,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":18,\"index\":0,\"itemVersion\":\"OSRELWin3.8.0\"},{\"entryType\":19,\"index\":0,\"itemVersion\":\"OSRELWin3.8.0\"}],\"truePortedFromGraphicData\":true,\"portedVersion\":\"OSRELWin3.8.0\",\"portedFromGraphicData\":false}";

// inside GeneralData.Load()
if (isNullOrEmpty(data._graphicsData) || isNullOrEmpty(data._globalPerfData == null)
{
  data.graphicsData = GraphicsData.Load(_graphicsDataFallback); 
  data.globalPerfData = GlobalPerfData.Load(_globalPerfDataFallback, _graphicsDataFallback);
}
else
{
  data.graphicsData = GraphicsData.Load(data._graphicsData); 
  data.globalPerfData = GlobalPerfData.Load(data._globalPerfData, data.graphicsData); 
 }

what do you think?

bagusnl commented 10 months ago

Fixed as of https://github.com/CollapseLauncher/Collapse/commit/f8d7b6c043e7e7ac05035ebc928e2947fe8a10b0 image

Closing this issue for now, the fix will come to next preview (and possibly stable) version.

Thank you for bringing this issue to us!