mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-14 18:01:20 +08:00
3c424fc34e
init() took a context unconditionally, including for compositions whose transitions are all CSS crossfades — they never compile a program, upload a texture or draw, so the context was pure waste against a hard browser limit (~16 concurrent contexts, oldest silently dropped). ensureGl() now creates the context, its resources and its context-loss handlers on first use, from the two paths that genuinely need one: the texture-upload choke point and the shader draw in tickShader(). A cache therefore starts with a null program and learns it from syncCacheProgram() when the context comes up (and again after a restore), which also takes over degrading a shader that fails to compile to the CSS crossfade path. Because prog is null before the context exists, it can no longer stand alone as the "this transition is a CSS crossfade" test — that would strand real shader transitions in the always-ready fallback state and skip their prewarm. Each cache now records the authored shader name and answers from that, which also drops three transitions[cache.index] lookups that assumed the cache and transition arrays stay index-aligned. Also drops the WebGL-unavailable early return: unavailability is now discovered on first use, and every transition degrades to a DOM crossfade instead of returning a timeline with no scene visibility management at all.