Race the CDN and the proxy, for thumbnails and for playback
A thumbnail used to try the provider and only ask /api/image once that had failed, so every hotlink-blocked host cost a wasted request per card before anything appeared. Both routes now go out together for the first thumbnail of a host, and the rest of the batch waits on that one answer rather than each rediscovering it. Speed decides which image is shown; capability decides what the host is remembered as, since the proxy tends to win first contact merely for being same-origin -- pinning a host to it over that would push a whole page of thumbnails through our own server. Playback asks the same question, but per video and at play time: one provider can spread its media over several CDNs, so there is nothing useful to pre-compute, and the old per-card probe answered for whichever card happened to scroll past. The direct route is now tested alongside the proxied playback and takes over if it answers before a frame is decoded. Whatever loses is cancelled -- the token guards stopped stale callbacks but left their requests running, so the losing route kept pulling bytes and the server kept an upstream connection open for them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QBDkEXP4htyXTCZUwMLphd
This commit is contained in:
@@ -424,7 +424,7 @@ App.feed = App.feed || {};
|
||||
const liveBadge = v.isLive ? '<span class="live-badge feed-live-badge">● LIVE</span>' : '';
|
||||
const favKey = App.favorites ? App.favorites.getKey(v) : null;
|
||||
slide.innerHTML = `
|
||||
<img class="feed-poster" src="${v.thumb || ''}" alt="" loading="lazy" decoding="async">
|
||||
<img class="feed-poster" alt="" loading="lazy" decoding="async">
|
||||
<video class="feed-video" muted playsinline webkit-playsinline preload="none"></video>
|
||||
${liveBadge}
|
||||
${favKey ? `<button class="favorite-btn feed-fav-btn" type="button" data-fav-key="${favKey}" data-fav-url="${v.url || ''}"></button>` : ''}
|
||||
@@ -446,7 +446,7 @@ App.feed = App.feed || {};
|
||||
</div>
|
||||
`;
|
||||
const poster = slide.querySelector('.feed-poster');
|
||||
App.videos.attachNoReferrerRetry(poster);
|
||||
App.videos.attachThumbnail(poster, v.thumb);
|
||||
const slideVideo = slide.querySelector('.feed-video');
|
||||
bindTimeline(slide, slideVideo);
|
||||
bindSharedControls(slide, slideVideo, v);
|
||||
|
||||
Reference in New Issue
Block a user