Investigate: Reinitialize EventChannel<_>
for states with custom dispatchers
#119
Closed
3 tasks done
Labels
F: core
Core application functionality - managing resources, state, etcetera.
Milestone
In GitLab by @azriel91 on May 2, 2019, 23:03
For states with custom dispatchers (including every state that
impl AppState
),System
s which registerReaderId
s againstEventChannel<_>
s will be dropped when theState
ends. This means those event channels will persist in theWorld
, and cause a memory leak -- the reader never reads, so the event channel holds onto the events that have not been read by every reader.Attempting to re-initialize a channel in
State#on_stop
causes an index out of bounds error:This is further complicated by event channels that are long lived, such as
EventChannel<ControlInputEvent>
.Options:
Try to implementremove(ReaderId)
forEventChannel
inshrev
.This is part of
shrev 1.0
.Figure out what's still running the
System
s that try to read the event channel.InputToControlInputSystem
was doing a delta from the existingControllerInput
value against theInputEvent
value, and sending aControlInputEvent
if it didn't match. This meant it would always send an event for new entities with aControllerInput
component.!123 changes the behaviour to send
ControlInputEvent
s whenInputEvent
s are sent.Try to drop / initialize theEventChannel
somewhere else (note,AppState
sets up the dispatcher before callingon_start
on the delegate).Bad solution -- it's hard to discover who is replacing the
EventChannel
.Register all systems in the main dispatcher, use state specific status types to decide whether to:
Try to drop the
ReaderId
inState#on_stop
Needs more thought. See Improve
ReaderId
rustgd/shrev-rs#28 (comment)The text was updated successfully, but these errors were encountered: