morethanwords/tweb/master • b6d3b05 • 10 files, +281/-15
Support chat-specific hashtag and cashtag search
morethanwords/tweb/master • 293cb45 • 8 files, +233/-9
Stop a stalled spoiler renderer from bricking a chat
A chat with a media spoiler in it could become permanently impossible to open:
the container went active but the topbar and input kept their `hide` class, the
bubbles stayed in a detached `chatInner`, and nothing was logged anywhere.
The chain started at the shader fetch. `DotRendererCore.shaderTexts[url] ??= fetch(url)`
memoized the request forever, so once it stalled every later attempt inherited the
same dead promise; `init()` memoized its failure the same way. The worker only posts
`media-inited` after `init()` resolves, so `DotRenderer.mediaWorkerReady` — a static
deferred, with `mediaInited` latched true and no retry — stayed pending for the rest
of the session. `wrapMediaSpoiler` awaits it, so that bubble's render promise never
settled, and `processBatch`'s `Promise.all(...).catch(noop)` waited on it forever:
`.catch` covers a rejection, never an answer that simply does not arrive. Behind it
queued `performHistoryResult` and then `Chat.setPeerPromise`, and `setPeer`'s early
return on a pending `setPeerPromise` turned every retry into a silent no-op.
Bound each step so no single stuck promise can latch permanently:
* never memoize a failed shader fetch or a failed `init()`, and give the fetch a
timeout, so the next spoiler retries instead of inheriting a dead promise
* give up on the worker's `*-inited` answer after a deadline: resolve the deferred
(the spoiler degrades to its blurred thumbnail, which still covers the media) and
unlatch `*Inited` so the next spoiler re-sends the init
* bound `wrapMediaSpoiler`'s wait on the dot canvas — it is decoration on top of an
already-covering thumbnail and must never hold up the message batch
* bound the batch's media `Promise.all`; the bubbles are already built, so at worst
some media finishes loading after mount instead of before it
* expire the in-flight peer-change dedupe, so an abandoned change stops swallowing
every attempt to reopen the chat
Also fixes a null deref in `replaceSharedMediaTab`, which threw on `tab.container`
when both the previous tab and the new one were undefined, aborting the peer change
that called it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
morethanwords/tweb/master • 12fbb85 • 2 files, +119/-2
Isolate fastRaf callbacks so one throw cannot poison the batch
Callbacks batched into a single frame are unrelated to each other, but `fastRaf`
ran them with a bare `forEach`, so the first one to throw cancelled every callback
queued behind it. `fastRafPromise` resolves from a callback queued in exactly that
way and caches its promise in a module-level variable that is only cleared once the
promise resolves — losing that resolve leaves it pending forever, and every later
`fastRafPromise()` hands out the same dead promise. Awaiting one is enough to park
a render path for the lifetime of the tab, silently.
`fastRafConventional` had the same hazard with an extra edge: a throw escaping its
loop also left the queue non-empty and `processing` stuck true, degrading every
later call to synchronous execution.
Run each callback in isolation and log what it threw, so a broken callback fails
alone instead of taking the frame's other work with it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
#webk
Post #20926
80
- 🫡 3