CollapseLauncher / Collapse

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

[Bug]: Unhandled error while updating #246

Closed 3stantedja closed 1 year ago

3stantedja commented 1 year ago

Affected Version

Collapse 1.71.8-PRE

Bug Behavior

I got an error with something like the following while updating Genshin Impact to 4.0.1:

System.NullReferenceException: Oops, the launcher cannot finalize the installation but don't worry, your game has been totally updated.
    Please report this issue to our GitHub here: https://github.com/neon-nyan/CollapseLauncher/issues/new or come back to the launcher and make sure to use Repair Game in Game Settings button later.
Throw: System.NullReferenceException: Object reference not set to an instance of an object.
   at Hi3Helper.Http.Http.InitializeMultiSession() in W:\GitHub Repos\Collapse\Hi3Helper.Http\Class\Session\SessionManager.cs:line 203
   at Hi3Helper.Http.Http.Download(String URL, String Output, Byte ConnectionSessions, Boolean Overwrite, CancellationToken ThreadToken) in W:\GitHub Repos\Collapse\Hi3Helper.Http\HttpMulti.cs:line 46
   at CollapseLauncher.InstallManager.Base.InstallManagerBase`1.RunPackageDownloadRoutine(GameInstallPackage package, CancellationToken token, Int32 packageCount) in W:\GitHub Repos\Collapse\CollapseLauncher\Classes\InstallManagement\BaseClass\InstallManagerBase.cs:line 1172
   at CollapseLauncher.InstallManager.Base.InstallManagerBase`1.InvokePackageDownloadRoutine(List`1 packageList, CancellationToken token) in W:\GitHub Repos\Collapse\CollapseLauncher\Classes\InstallManagement\BaseClass\InstallManagerBase.cs:line 1143
   at CollapseLauncher.InstallManager.Base.InstallManagerBase`1.StartPackageDownload(Boolean skipDialog) in W:\GitHub Repos\Collapse\CollapseLauncher\Classes\InstallManagement\BaseClass\InstallManagerBase.cs:line 178
   at CollapseLauncher.Pages.HomePage.UpdateGameDialog(Object sender, RoutedEventArgs e) in W:\GitHub Repos\Collapse\CollapseLauncher\XAMLs\MainApp\Pages\HomePage.xaml.cs:line 1611
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Hi3Helper.Http.Http.InitializeMultiSession() in W:\GitHub Repos\Collapse\Hi3Helper.Http\Class\Session\SessionManager.cs:line 203
   at Hi3Helper.Http.Http.Download(String URL, String Output, Byte ConnectionSessions, Boolean Overwrite, CancellationToken ThreadToken) in W:\GitHub Repos\Collapse\Hi3Helper.Http\HttpMulti.cs:line 46
   at CollapseLauncher.InstallManager.Base.InstallManagerBase`1.RunPackageDownloadRoutine(GameInstallPackage package, CancellationToken token, Int32 packageCount) in W:\GitHub Repos\Collapse\CollapseLauncher\Classes\InstallManagement\BaseClass\InstallManagerBase.cs:line 1172
   at CollapseLauncher.InstallManager.Base.InstallManagerBase`1.InvokePackageDownloadRoutine(List`1 packageList, CancellationToken token) in W:\GitHub Repos\Collapse\CollapseLauncher\Classes\InstallManagement\BaseClass\InstallManagerBase.cs:line 1143
   at CollapseLauncher.InstallManager.Base.InstallManagerBase`1.StartPackageDownload(Boolean skipDialog) in W:\GitHub Repos\Collapse\CollapseLauncher\Classes\InstallManagement\BaseC
lass\InstallManagerBase.cs:line 178
   at CollapseLauncher.Pages.HomePage.UpdateGameDialog(Object sender, RoutedEventArgs e) in W:\GitHub Repos\Collapse\CollapseLauncher\XAMLs\MainApp\Pages\HomePage.xaml.cs:line 1611
   --- End of inner exception stack trace ---

I did restart the launcher and it appears that it hadn't downloaded the second part (en-us_4.0.0_4.0.1_hdiff_lHMOr4c5a1mtS836.zip) so it gets stuck trying to download and failing once more. It does say that the file itself is 22B (with it being essentially empty save for file metadata) which I think might've tripped it up.

Expected Behavior

It should be able to successfully download an update.

Steps to reproduce

  1. Open launcher
  2. (if not on Genshin Impact) Switch game to Genshin Impact
  3. Click on "Update Game"
  4. Either click on "Yes, Resume" or "No, Start Over"

Related Issues

No response

Screenshot(s)

image

Additional Information

DxDiag.txt log-2023-08-23-pre1.71.8-id1.log

bagusnl commented 1 year ago

Seems like your connection to mhy download server has some problem. Can you try a VPN or some sort and see if Collapse can download the file?

ikenxuan commented 1 year ago

i also had this problem, but i am using mihuyo China's server image

bagusnl commented 1 year ago

Currently testing

bagusnl commented 1 year ago

Seems like the file size is not the issue. All audio package I have is also 22bytes in size. Also I can't seem to reproduce the exception

3stantedja commented 1 year ago

Might be a nuclear option, but would reinstalling the launcher and see if the exception comes up again help?

bagusnl commented 1 year ago

I have analyzed the update files and seems that the game update today is just engine update. There are no assets being updated. So you guys can download the files manually (just the game file stated in the Collapse log/console) then extract it manually on the root of the game folder. Before launching collapse/the game, please make sure the game_version inside the config.ini is 4.0.1, then you should be able to run Collapse and the game

bagusnl commented 1 year ago

I also want to hijack this issue to tell people that has problem in game repair on 4.0.1 that we have identified an issue in game repairing on collapse and currently working on the issue

ikenxuan commented 1 year ago

I manually downloaded this zip to the game folder, and after I let Collapse decompress it, I was able to enter the genshen impact 4.0.1 version normally

3stantedja commented 1 year ago

Ditto, after placing the empty file and let Collapse download the engine update it downloads and updates the game as per normal.

*(ie. place en-us_4.0.0_4.0.1_hdiff_lHMOr4c5a1mtS836.zip on Genshin Impact's root folder, and then let Collapse resume the update to download the rest of the update)

bagusnl commented 1 year ago

Sorry if it took quite a long time, but we finally identified the issue. The issue lays on how our Http module splits the download into chunks to download the file multithreaded. As the method tries to split the file, if the file size is too small for the download thread that it sets on, it freaked out and throws an exception on InitializeMultiSession().

Fix proposal: Implement a check to check if the file size to download in MultiSession is not too small, if it is then download it in singlethread.

neon-nyan commented 1 year ago

Hi @3stantedja,

As per our internal discussion regarding to this issue, we have come with a fix in the recent commit. However, this fix isn't yet applied to the current Preview and Stable. But we will include this fix in the next version of both releases.

3stantedja commented 1 year ago

thanks for the response! i forgot that i've filed this bug to be honest. it's good to hear that the cause is found. understandable that it takes a while to find the cause, but i appreciate the responses and the support given to us!

bagusnl commented 1 year ago

Adding to neon's comment above, we have now released a hotfix with commit that should mitigate this issue. Shall the same or similar issue reappears, feel free to anyone to reopen or open a new issue ticket.

Thank you for everyone involved in this ticket and thank you also for continuous support for Collapse project!