CollapseLauncher / Collapse

An Advanced Launcher for miHoYo/HoYoverse Games
MIT License
1.37k stars 64 forks source link

[Help] Internet Disconnection while locally testing an IT localization #51

Closed muscularcandy67 closed 1 year ago

muscularcandy67 commented 1 year ago
System.Net.Http.HttpRequestException: HttpResponse has returned unsuccessful code: RequestedRangeNotSatisfiable
   at Hi3Helper.Http.Http.InitializeSingleSession(Nullable`1 OffsetStart, Nullable`1 OffsetEnd, Boolean IsFileMode, Stream _Stream) in D:\Repo\CollapseLauncher\Hi3Helper.Http\Class\Session\SessionManager.cs:line 49
   at Hi3Helper.Http.Http.<>c__DisplayClass61_0.<Download>b__0() in D:\Repo\CollapseLauncher\Hi3Helper.Http\Http.cs:line 120
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Hi3Helper.Http.Http.Download(String URL, Stream Outstream, Nullable`1 OffsetStart, Nullable`1 OffsetEnd, CancellationToken ThreadToken) in D:\Repo\CollapseLauncher\Hi3Helper.Http\Http.cs:line 119
   at CollapseLauncher.MainPage.TryGetMultiLangResourceProp() in D:\Repo\CollapseLauncher\CollapseLauncher\Classes\BackgroundManagement\BackgroundManagement.cs:line 98
   at CollapseLauncher.MainPage.FetchLauncherLocalizedResources() in D:\Repo\CollapseLauncher\CollapseLauncher\Classes\BackgroundManagement\BackgroundManagement.cs:line 36
   at CollapseLauncher.MainPage.IsTryLoadGameRegionTaskFail(Task InnerTask, UInt32 Timeout) in D:\Repo\CollapseLauncher\CollapseLauncher\Classes\RegionManagement\RegionManagement.cs:line 130

image image As you can see, I'm locally doing an Italian translation for the launcher (WIP, will create a Pull Request once it's done), and this happens while switching to Genshin Impact Global. With All Honkai regions works fine, with Genshin China works fine. The commit using (not considering the IT localization) is 7c4cfeafeeddc01aad4239db788d9be10a884aee

neon-nyan commented 1 year ago

I think it's because the official launcher's API itself doesn't support it-IT localization. As per my investigation below, the API doesn't have any value for it-IT localization.

image

Compared to other languages, the API seems to be supporting it (for example: fr-FR - French)

image

Even the language doesn't have support with the API, it should be failing back to en-US - English localization instead. I will try to investigate this.

muscularcandy67 commented 1 year ago

Seems like I discovered a potential flaw for eventually other translation

neon-nyan commented 1 year ago

This issue should've been addressed in these commits: https://github.com/neon-nyan/CollapseLauncher/commit/3bae095f5b1d2cd5ece84a07706f70f16fe068c6 https://github.com/neon-nyan/CollapseLauncher/commit/4a8161062f2c87364751a864d563aec7733da32e

Anyway, the language support is out of Collapse Launcher's scope and it depends on miHoYo's official launcher API. Making it to set the fallback value (as en-us) will help to fix this issue.

muscularcandy67 commented 1 year ago

Gonna pull the commits and try to compile

muscularcandy67 commented 1 year ago

Works. Although I have a question. The issue happened because it tried to contact Genshin Impact Global server with it-IT localization and it failed?

neon-nyan commented 1 year ago

Works. Although I have a question. The issue happened because it tried to contact Genshin Impact Global server with it-IT localization and it failed?

Yes, but to be exact. The API returns an empty response to the launcher because the API doesn't support the localisation. At the same time, the launcher was failing to re-send the request using fallback localisation because of unhandled exception from the new System.Text.Json Deserializer.