fix: the contacts app's wait for custom NPCs survives a broken NPC in the scene - #337
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… the scene WaitForNPCs polled FindObjectsOfType<NPC>(true) every frame and read each one's ID. On IL2CPP, on the second load of a session, one inactive NPC in the scene throws from NPC.ID (its data object is gone), so every poll threw: 1,222 "Exception in IL2CPP-to-Managed trampoline" errors in 47 s in one run. The predicate never returned true for the rest of the session. The check now skips an NPC whose ID throws, matches IDs through a set instead of a nested search, and runs four times a second instead of every frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
da4b3c1 to
e353ecf
Compare
|
I pushed 9ec0598 to remove the comment that repeated the throwing-ID test. Kept the runtime scan-throttling explanation and XML docs. No runtime changes in this follow-up. Full builds and suites pass: 743 Mono, 723 IL2CPP. |
|
Tested on 0.4.7f7 Mono and IL2CPP. Dealer and supplier contacts initialized on the first load and after reloading, even with nine scene NPCs throwing when their ID was read. CI passed. The combined build of #332, #333, #334, #336 and #337 also passed all 770 Mono and 744 IL2CPP tests. Merged into beta. |
Summary
ContactsAppPatches.WaitForNPCschecked every frame that each physical custom NPC was in the scene. It did this by readingNPC.IDfor every result ofFindObjectsOfType<NPC>(true). Some of the game's own NPCs throw fromIDon IL2CPP: the pooledNPCs/SpecialCustomers/SpecialCustomerNPC(Clone)andSpecialCustomerLeaderNPC(Clone). One throw fails the whole check. On the second load of a session the wait is still running once they exist, so it threw every frame for the rest of the session:That was 1,222 errors in 47 s in one run.
The change.
IDthrows is skipped. It's never one of the custom NPCs being waited for.Compatibility
Validation
Mono
dotnet build S1API.sln -c MonoMelon --no-restore -p:AutomateLocalDeployment=false: 0 errors, 0 warnings.dotnet test ... -c MonoMelon: 743 passed (740 onbetaplus 3 new: a throwing NPC id is skipped, a missing NPC is still waited for).IL2CPP
dotnet build S1API.sln -c Il2CppMelon --no-restore -p:AutomateLocalDeployment=false: 0 errors, 0 warnings.dotnet test ... -c Il2CppMelon: 723 passed (720 plus 3 new).Runtime evidence
How it was tested. Automated runs on 0.4.7f7 load a save, teleport to each custom NPC, record whether its model is shown and its network state, return to the menu and load again. They used a combined build of #332 to #339.
I also played the IL2CPP case by hand.
Before/after on IL2CPP without Polyfill or S1UMF (S1UMF guards
NPC.IDitself, which hides the bug). The before build is all of #332 to #339 except this one; the after build is all of them. The probe counted the relation circles in the contacts app.WaitForNPCsOn Mono there were no errors either way.
Documentation
None needed.
🤖 Generated with Claude Code