MAJOR weak_map GetSession() broken in 26.10

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Verse

Summary

weak_map GetSession() broken in 26.10. when I use the weak_map setup to save an int in between rounds it no longer works, it does not save. See video

Steps to Reproduce

See video for code or see here, the button I press ends the round:
verse file 1:

using { /Verse.org/Simulation }

var GlobalInt:weak_map(session,int) = map{}
Func():void={
    if(A := GlobalInt[GetSession()]):
        if(set GlobalInt[GetSession()] = 2){} 
    else:
        if(set GlobalInt[GetSession()] = 1){} 

    
    if(A := GlobalInt[GetSession()]):
        Print("A {A}")
}

verse file 2:

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

testdevice := class(creative_device):
    OnBegin<override>()<suspends>:void=
        Func()

Expected Result

It save between rounds, in round 2 the value should be 2 (or print ā€œA 2ā€)

Observed Result

Platform(s)

PC

The status of UCB-909 incident has been moved from ā€˜Doneā€™ to ā€˜Closedā€™.

3 Likes

Weā€™ve verified the same in our islands. Can confirm it is broken since yesterday.

Can confirm the issue as well.

Broken on my end too.

1 Like

Really annoying bug, but they did change something in the digest about weak maps so I wonder if its intentional?

1 Like

For your information.

v26.00

    # Type for which there is a single value per server instance.  Use `GetSession` to get the current server instance `session`.  May be used with `weak_map` to mimic global variables in other languages.
    session<native><public> := class<unique><module_scoped_var_weak_map_key><epic_internal>:

    # Returns the `session` corresponding to the current server instance.  The result can be used with `weak_map` to mimic global variables in other languages.
    GetSession<native><public>()<varies>:session

v26.10

    # Type for which there is a single instance per round.  Use `GetSession` to get the current round's `session` instance. May be used with `weak_map` to implement global variables.
    # Note: may be changed in a future release to a single instance per game. Round-local behavior should not be relied upon.
    session<native><public> := class<unique><module_scoped_var_weak_map_key><epic_internal>:

    # Returns the `session` corresponding to the current round.  The result can be used with `weak_map` to implement global variables.
    # Note: may be changed in a future release to return a single instance per game. Round-local behavior should not be relied upon.
    GetSession<native><public>()<varies>:session
1 Like

Looks either intentional or someone accidentally reverted to an older version of the file before packaging the release.

1 Like

These Notes are still there in the Verse digest for version 26.20, hinting that nothing got touched in that area.

1 Like

This is unfortunately intended. Use of session as a key in a module-scoped var weak_map may eventually gain back support for cross-round state (hence the scary ā€œNote: ā€¦ā€ part of the doc), but it was removed in 26.10. To protect against a behavior change (when cross-round state is added back), make sure to initialize your state at the beginning of OnBegin in a creative_device, e.g.

if:
  set GlobalInt[GetSession()] = 0
2 Likes

(1) Any feel if they will be adding it back in the next upgrade? The change broke a lot of islands. Thanks!

(2) Is there any work around to keep an int or float between rounds?

PSā€” very weird, but I have an island where my two session variables work perfectly when running a session from the editor, but like everyone elseā€™s, they fail when published.

1 Like

Unfortunately, I canā€™t give any information about when it will be added back, even for int or float. Can you can more details about session variables working in the editor, but not when published?

1 Like

I could supply the island, but the bizarre thing is that I made a fresh ā€œhello worldā€ map using a weak mapped session-to-int variable, and it didnā€™t even work in the editor. I literally copied and pasted Epicā€™s example from the documentation.

I broke the process down into three steps and (a) writing to a weakly mapped session variable has no problem, (b) reading from that same variable in the same session, no problem (c) ending and restarting the game completely erases the previously stored variable.

On the other hand, my map created before the last two upgrades saves the round number(int) and shortest completion time (float) absolutely perfectly between rounds when run from the editor. You can play ten games in the same session, and it works every single time. Not in Fortnite.

This makes me think that projects created before the last two updates have the works-in-the-editor-not-in-the-game property, while projects created afterword never retain the global, session value in either in UEFN or in Fortnite. Itā€™s like there is a storage spot for global variables in Islands created before the last two patches that no longer exists for newly created maps.

I posted this all in a bug report, my ā€œhello worldā€ map referred to in the report is the simplest possible map that displays the property, so it may save some time if someone is working on the issue. I can supply my old map if you want to look at something that works in the editor, itā€™s fairly involved though.

Bug Report
Private island with works-in-editor session variables: #8168-1632-6083