KittenApps / WCE

Wholesome Club Extensions (WCE) - enhancements for BC - fork of FBC 5.8
https://wce-docs.vercel.app
GNU General Public License v3.0
5 stars 3 forks source link

[BUG] Extended Wardrobe: new accounts fail to sync (does not initialize FBCWardrobe) #55

Closed leralc closed 8 hours ago

leralc commented 3 days ago

Summary

It appears that on new accounts that have not previously had the Extended Wardrobe option enabled, WCE is presently failing to initialize the ExtensionSetting for it, leading to an extended wardrobe that will appear in the UI, but whose outfits will disappear following a refresh as the values are not synced to the BC server.

This was discovered in the wild by a friend of mine (whose account was created recently and noticed the issue when outfits saved to WCE slots [slot # > 24] disappeared after refreshing), and was narrowed down after a short debugging session. They were able to replicate the issue on their main & alt (all relatively new accounts -- potentially prior to the FBC -> WCE transition, if that's related?), and I was able to replicate the issue on a completely fresh account myself, but cannot say for certain whether there was any additional factor that was overlooked.

I have included details on the environments in which the bug has been successfully reproduced, as well as detailed repro instructions below. If you're unable to replicate the bug, please let me know, and I can see if there's something I've missed, as I haven't spent too much time looking into this.

Environments

Expand for details BC: R110 1. - OS: Windows 10 - Browser: Firefox - UserScript Manager: Violentmonkey - Scripts: FUSAM, Additional External Scripts (No Overlap w/ Other Environments) - WCE Channel: Stable 2. - OS: Windows 10 - Browser: Firefox - UserScript Manager: Tampermonkey - Scripts: FUSAM, Additional External Scripts (No Overlap w/ Other Environments) - WCE Channel: Stable 3. - OS: Windows 10 - Browser: Edge - UserScript Manager: Tampermonkey - Scripts: FUSAM, Additional External Scripts (No Overlap w/ Other Environments) - WCE Channel: Stable

Reproduction

  1. Create a brand new BC account
  2. Acquire a wardrobe (purchase private room & wardrobe)
  3. Enable WCE in FUSAM (unsure if timing matters, but this is when I did it)
  4. Configure WCE: Settings -> Extensions -> WCE -> Appearance & Wardrobe -> Extended wardrobe slots (96)
  5. Optional: Refresh BC (only required if slots don't show up -- can't remember)
  6. Create a recognizable outfit and save to an Extended Wardrobe slot (not a native BC slot, slot # > 24)
  7. Optional: run Player.ExtensionSettings in console and notice that FBCWardrobe does not exist
  8. Refresh the page
  9. Return to the wardrobe and attempt to load the outfit
  10. Observe that the previously saved outfit no longer exists/can't be loaded
  11. Optional: run Player.ExtensionSettings in console and notice that FBCWardrobe does not exist

Additional Notes

A hacky patch that I have successfully used to fix this bug in the meantime is to manually initialize the FBCWardrobe value, sync it, and refresh, after which FBC successfully updates the setting and normal functionality resumes:

Player.ExtensionSettings.FBCWardrobe = LZString.compressToUTF16(JSON.stringify([]));
ServerPlayerExtensionSettingsSync("FBCWardrobe");
leralc commented 3 days ago

With no knowledge of the codebase, it appears the only place FBCWardrobe is directly handled is in https://github.com/KittenApps/WCE/blob/main/src/functions/extendedWardrobe.ts#L47, where creation only occurs on a migration from BCEWardrobe, and not if neither presently exists.

KittenApps commented 3 days ago

This got broken while trying to fix incompatibilities with some other misbehaving addons in https://github.com/KittenApps/WCE/commit/d9e96661285d133897b8de5c249ffeae4d5a8d6f

I think this safeguard should really stay there, so a better fix would be to maybe check when the extended Wardrobe is enabled in settings, if the save data exists and if not create it. That reduced the number of times when something could go wrong from every addonh load to only when reenabling the extended wardrobe.

leralc commented 7 hours ago

@KittenApps

Thanks! Looks like the fix works (S/O aforementioned friend for testing while I was away). Something to note though is that since the fix only initializes FBCWardrobe when the setting is toggled (from what I can tell), it won't do anything for anyone who had enabled the setting during the past 3 months in which the bug was present.

Since the bug is rather difficult to track down/pinpoint and all the normal end user would know is that "outfits past X tab disappear after relog", they may not know to toggle the setting to fix it. Ideally, there should be a retroactive fix or a prominent notice of some sort.

KittenApps commented 3 hours ago

I know, I'm a bit hesitant for a more aggresive fix, because I know people lost their wardrobe in the past, because some other faulty addon made loading the extended wardrobe fail and WCE just overwrote the stored extended wardrobe with that faulty empty data then.

But yeah that should be announced in the changelog once it's released to stable.

leralc commented 1 hour ago

Ahh, I see. Make sense then, hopefully the changelog gets the point across.