@@ -6,6 +6,7 @@ use crate::{
6use bumpalo::Bump;
6use bumpalo::Bump;
7use fxhash::{FxHashMap, FxHashSet};
7use fxhash::{FxHashMap, FxHashSet};
8use std::sync::atomic::{AtomicUsize, Ordering};
8use std::sync::atomic::{AtomicUsize, Ordering};
9use wasm_bindgen::prelude::*;
10use wasm_bindgen::prelude::*;
11static ID_COUNTER: AtomicUsize = AtomicUsize::new(0);
12static ID_COUNTER: AtomicUsize = AtomicUsize::new(0);
@@ -101,7 +102,9 @@ impl CachedSet {
103 fn next_id(&mut self) -> CacheId {
104 fn next_id(&mut self) -> CacheId {
104− CacheId(ID_COUNTER.fetch_add(1, Ordering::AcqRel) as u32)
105+ let next = ID_COUNTER.fetch_add(1, Ordering::AcqRel) as u32;
106+ let next = if next == u32::MAX { None } else { Some(next) };
107+ CacheId(next.expect_throw("ID_COUNTER overflowed"))
107 pub(crate) fn insert<F>(cx: &mut RenderContext, f: F) -> CacheId
110 pub(crate) fn insert<F>(cx: &mut RenderContext, f: F) -> CacheId