Weakmap Runtime Errors W/ Player.IsActive[] passing.

Summary

Getting a concerning amount of these errors

Verse unrecoverable error: ErrRuntime_WeakMapInvalidKey: Invalid key used to access persistent `var` `weak_map`. (Invalid key used to access persistent `var` `weak_map`.) (Callstack unavailable)

Every single one of my weak_maps is marked <internal> inside of modules only allowing read / write via <public> functions that ensure InPlayer.IsActive[] before doing anything this leads me to believe that IsActive[] is passing when it should not. Please see the example below.

Module_Example <public> := module:

    some_class <public> := class<final><persistable><concrete>:
        some_flag <public> : logic = false
        some_data <public> : int = 0

    var SomeInternalWeakMap <internal> : weak_map(player, some_class) = map{}

    GetSomeClass<public>(Agent:agent)<transacts><decides>:some_class=
        Player := player[Agent]
        Player.IsActive[]
        SomeClass := SomeInternalWeakMap[Player]
        return SomeClass

    UploadSomeClass<public>(Agent:agent, SomeClass:some_class)<transacts><decides>:void=
        Player := player[Agent]
        Player.IsActive[]
        FitsInPlayerMap[SomeClass]
        set SomeInternalWeakMap[Player] = SomeClass

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Stability

Steps to Reproduce

Copy Snippet & Publish

Expected Result

Player.IsActive[] passing not leading to runtime errors

Observed Result

Player.IsActive[] either passes when it shouldn’t or something is wrong with player weak_map’s

Platform(s)

Windows

Island Code

6872-6995-0659

Additional Notes

I am using 3 total player weakmaps, not one them is accessible directly, they all go through the exact same process provided in the snippet.

Hey @Jpt96 i have a couple questions that will help us reproduce and get a potential fix in

Does this runtime eror occur in a Edit Session?

Do you have a Runtime Error Code you can share?

Thanks!

I have not been able to reproduce it in edit sessions, but it has happened in a playtest code once.

I do have a report id from the runtime errors in the portal

Report ID`[844f7fe161671b9d8d675256cab2b425]`

Modules f02876b0-432b-1958-aa59-068c5e484924 v927

1 Like

Hi @Jpt96 apologies for the delayed response on this. I do see that you made some updates to the Verse code with IsActive[] checks to guard against potential invalid accesses of disconnected players and indexing into the weak_map, which will trigger a Verse runtime error. Are you still running into this issue since then?

Hi @sonictke We had to ensure the FortCharacter was moving prior to initializing the weak_map for the player. That was our workaround for the time being. It did seem to fix the issue currently. This issue has been also happening for Join In Progress players.

FORT-989854 is ‘Closed’ as ‘Fixed’. The issue will be addressed in 40.00.