Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backmerge hotfixes #292

Merged
merged 18 commits into from
Apr 30, 2024
Merged

Conversation

belettee
Copy link
Contributor

No description provided.

mihaicm93 and others added 18 commits April 21, 2024 23:08
### Request For Comment

Hotfix to master, will require back-merge to develop.

Apologies for wall of text. This hotfixes at least one cause of black
screen (seen at least in ~2~ ~3~ ~4~ 5 player reports) and adds a
best-effort `try/finally` to save end-of-raid progress.

**Hotfix**
See stacktrace below. Basically, one UI element (trader rep section)
wants to get called when player levels up (like at the end of a raid) to
update its "next trader level requirements" UI. Thing is, that piece of
UI is not around anymore/yet at the end of the raid, so it crashes. I'm
not sure why the hook does not get properly unregistered (presumably on
scene unload). I hate having to use a patch for that, but the hook is so
deep, I haven't found a better approach. Open to suggestions. Note that
issues with black screen at end-of-raid have been reported in vanilla
and SPT as well.

**Best-effort save end-of-raid progress** 
On top of fixing the above, I added a try/finally around the end-of-raid
code (C1) to make sure we make the network call to the Aki backend to
save progression. Two worries about doing that if an exception is thrown
in C1:
- some important code could have been skipped, maybe some
profile-related stuff, so there's a risk that what gets sent to Aki is
not what we want, depending on what `Player.OnGameSessionEnd`,
`CoopSITGame.CleanUp` and `BackEndSession.OfflineRaidEnded` do as of
today, and in the future
- the client probably needs to be restarted because a lot of UI
consistency/cleanup stuff is happening in C1, like unregistering hooks,
etc. even if the progression properly gets saved.

**Choices to make** @paulov-t
1) regarding saving progression, do we really want to do a best-effort
to make the backend request? On the one hand, it's unlikely that
profiles get corrupted from that, and hopefully people make backups (or
the launcher could do it daily). On the other hand, if an end-of-raid
logic exception is thrown, we now have nice logs sent by users + a
hotfix-friendly master/develop branch system so we could just get a fix
out quickly. Both are fine with me, the latter has less catastrophic
failure modes and avoids UI consistency issues.
2) if we do go with the best-effort try/finally and an exception is
thrown, should we display a fatal error popup explaining what happened,
or just hope that the UI isn't too wonky even without the proper
cleanup? Think popup would be the way to go.

Error was:
```
NullReferenceException
  at (wrapper managed-to-native) UnityEngine.Component.get_gameObject(UnityEngine.Component)
  at EFT.UI.UIElement.ShowGameObject () [0x00000] in <305d2033b20e43a1983675b0792a75c5>:0 
  at EFT.UI.RankPanel.Show (System.Int32 rankLevel, System.Int32 maxRank) [0x00000] in <305d2033b20e43a1983675b0792a75c5>:0 
  at TraderCard.method_0 () [0x0005a] in <305d2033b20e43a1983675b0792a75c5>:0 
  at (wrapper delegate-invoke) <Module>.invoke_void()
  at (wrapper dynamic-method) EFT.Profile+TraderInfo.DMD<EFT.Profile+TraderInfo::UpdateLevel>(EFT.Profile/TraderInfo)
  at EFT.Profile+TraderInfo.method_1 (System.Int32 _, System.Int32 __) [0x00000] in <305d2033b20e43a1983675b0792a75c5>:0 
  at (wrapper delegate-invoke) System.Action`2[System.Int32,System.Int32].invoke_void_T1_T2(int,int)
  at ProfileInfo.set_Experience (System.Int32 value) [0x00054] in <305d2033b20e43a1983675b0792a75c5>:0 
  at AStatisticsManagerForPlayer.EndStatisticsSession (EFT.ExitStatus exitStatus, System.Single pastTime) [0x00181] in <305d2033b20e43a1983675b0792a75c5>:0 
  at EFT.Player.OnGameSessionEnd (EFT.ExitStatus exitStatus, System.Single pastTime, System.String locationId, System.String exitName) [0x0005d] in <305d2033b20e43a1983675b0792a75c5>:0 
  at StayInTarkov.Coop.SITGameModes.CoopSITGame+<>c__DisplayClass96_0.<Stop>b__0 () [0x00042] in <88c5c3ff81d84133ad3383979cbeddd0>:0 
  at EFT.UI.PreloaderUI+Class2571.MoveNext () [0x000a9] in <305d2033b20e43a1983675b0792a75c5>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00026] in <ca21460feb9c47d0ac337b9893474cc6>:0 
```
Hotfix for now, but the whole extract+quit out logic will need to be
simplified/unified in the next major release.

Sequence of events triggering the bug:
- guest extracts (regardless of exfil type/map)
- guest's collider is disabled so that existing players do not get
bodyblocked
- no more collision with exfil point means `OnCancelExtraction` is
called, which has new "runner" detection logic, setting the exit status
to mia (restoring "default" value)
- host quits (i.e. pressed F8)
- host's `profileId` is before guest's `profileId` in the `Players` list
- host "kicks" all players including itself before it "kicks" the guest
- nodejs server sees host left, sends a "everybody leave now!" message
to all remaining connected players, including guest
- guest leaves without recomputing its exit status, which was set to MIA
by `OnCancelExtraction` above
- player sad
- got player report that it was still broken
- rewrote the fix after lots of testing
- looked at SPT for something else
- saw they had the exact same fix
- cried a little
- imported their stuff with proper credit to make sure we can stay
up-to-date and even contribute back
)

This removes the custom code we have around boss spawning since we
probably have no business handling that ourselves and so that we can be
more inline with SPT and mods.
Tested bosses and scavs are spawning fine, no cultist during the day.
@belettee belettee requested a review from paulov-t April 29, 2024 01:50
Copy link

badge

Build Successful! You can find a link to the downloadable artifact below.

Name Link
Commit 336501e
Logs https://github.com/stayintarkov/StayInTarkov.Client/actions/runs/8872175763
Download https://github.com/stayintarkov/StayInTarkov.Client/suites/23237670470/artifacts/1455168712

@paulov-t paulov-t merged commit ec8d178 into stayintarkov:development Apr 30, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants