web: Avoid bug in generational-arena (fix #1315)
An issue with Arena::clear allowed stale sound instance indices to be remain valid, causing certain sounds to be removed when they shouldn't (#1315). Workaround this issue by forcing Arena to bump the generational index.
This commit is contained in:
parent
37ead31b2a
commit
796805c31b
|
@ -786,6 +786,13 @@ impl AudioBackend for WebAudioBackend {
|
|||
}
|
||||
// TODO: Have to handle Decoder nodes. (These may just go into a different backend.)
|
||||
});
|
||||
// This is a workaround for a bug in generational-arena:
|
||||
// Arena::clear does not properly bump the generational index, allowing for stale references
|
||||
// to continue to work (this caused #1315). Arena::remove will force a generation bump.
|
||||
// See https://github.com/fitzgen/generational-arena/issues/30
|
||||
if let Some((i, _)) = instances.iter().next() {
|
||||
instances.remove(i);
|
||||
}
|
||||
instances.clear();
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue