Monarch preload() stuck when screen unregistered

Our game uses Monarch to occasionally show news messages in a popup whenever Monarch is idle (nothing on the stack, and not busy)

Separately, the player is able to take part in a seasonal event, which involves unloading the game world collection proxy (which contains the Monarch screens collection) and reloading it with different data.

If these situations coincide, Monarch starts to load the message popup as it’s being unloaded, and no progress is made. This has the consequence of blocking further UI interaction, as active_transition_count = 1, so Monarch.is_busy() returns true.

It’s not surprising that this doesn’t work and a refactor may be necessary but is there any way to cancel queued screen loads?

Logs below, notably preload() preloading done is not printed.

log
queue() empty
queue() adding function: 0x012e963fe0
queue() next action function: 0x012e963fe0
show_in() hash: [cms_message_popup] false
notify_transition_listeners() hash: [monarch_screen_transition_in_started]
change_context() hash: [cms_message_popup]
load() hash: [cms_message_popup]
preload() preloading screen hash: [cms_message_popup]
preload() proxy
unregister() hash: [share_popup]
unregister() hash: [new_pet_popup]
unregister() hash: [quests_panel_popup]
unregister() hash: [how_to_play_panel]
unregister() hash: [confirmation_popup]
unregister() hash: [cms_message_popup]

It shouldn’t be too hard to add. I can take a look if you create a feature request.

2 Likes

Includes a repro example.

1 Like

I’ve fixed the reported issue.

NOTE: I have also merged a breaking change in the way transition and focus changes are set up. Previously you had to set a transition or focus url to get notified when a transition was supposed to start or when a focus change happened. I have scrapped this system in favour of monarch.on_transition(id, cb) and monarch.on_focus_changed(id, cb).

2 Likes

Thank you!

In previous versions, transition_done was one of the messages received by a gui_script. How should developers meet this new requirement from the release notes? Do the ‘default’ transition types (transitions.slide_out_left etc) already do this? And then, how can a gui script detect when a transition is done?

When a transition is completed it is up to the developer to send a transition_done (constant monarch.TRANSITION.DONE ) message back to the sender to indicate that the transition is completed and that Monarch can continue the navigation sequence.

1 Like

Yes, the default transitions send monarch.TRANSITION.DONE automatically.

You can use monarch.add_listener() to get this information sent to your gui script if the script itself needs to know about it.

2 Likes

Message monarch_screen_transition_in_finished seems to be sent as soon as the transition starts. Is that deliberate? Parameter wait_for_transition is false inside show_in() , which seems to control that.

No, that doesn’t sounds right. Please create ticket on GH and I’ll take a look!

2 Likes