[Performance] LogoCarousel causes repeated image requests flooding backend on onboarding dialog #122
Conversation
|
CI failed because the commit subject did not conform to project specifications. The current commit message is:
The project requires the following format:
The current Allowed types include: Additionally, the subject only allows English letters, numbers, spaces, periods, hyphens, and underscores. Please resubmit. CI 未通过是因为 commit subject 不符合项目规范。 当前提交信息为:
项目要求格式为:
当前的 允许的类型包括: 另外,subject 仅允许英文、数字、空格、英文句号、连字符和下划线。 请重新提交~ |
|
@chenyme |
[Performance] LogoCarousel causes repeated image requests flooding backend on onboarding dialog
[Performance] LogoCarousel causes repeated image requests flooding backend on onboarding dialog
Environment
frontend/components/ui/logo-carousel.tsxInitialSecurityGuard→OnboardingFeatureCarousel→LogoCarousel/chatCurrent Behavior
When a newly registered user arrives at
/chat, the onboarding dialog displays an animated logo carousel cycling through 34 LLM vendor icons across 3 columns every 2 seconds. Each cycle renders new<img>elements pointing to/vendor/lobehub-icons/*.svg.Because
AnimatePresencewithmode="wait"unmounts the previous<img>and mounts a new one, the browser re-fetches these SVGs from the backend on every cycle. This occurs despite:Cache-Control: public, max-age=3600The result is a sustained stream of redundant HTTP requests and unnecessary TCP connections for as long as the dialog remains open.
Expected Behavior
All vendor logo SVGs should be fetched once when the carousel mounts and served from the browser cache for all subsequent animation cycles. Zero redundant network requests should occur during the carousel's lifetime.
Root Cause
No preloading —
LogoCarouselacceptsLogoCarouselLogoitems with optionalsrcURLs. When rendered, a raw<img>tag is created. The browser has no opportunity to pre-cache these imagesbefore the rapid cycling begins.
Unstable React keys — The animated wrapper uses
key={currentLogo.id}-${currentIndex}. SincecurrentIndexchanges every cycle, React tears down and recreates the DOM element, forcing thebrowser to re-resolve the image resource.
loading="lazy"conflicts withAnimatePresence— The<img>enters withopacity: 0+blur(8px), which can cause the browser to defer loading until the entrance animation is mid-flight, compounding the repeated-request problem.Proposed Fix
In
LogoCarousel:src-based logos on mount usingnew Image()to populate the browser cache before the carousel starts cycling.loading="lazy"— the images are always in-viewport, and the attribute interacts poorly withAnimatePresenceentrance animations.Affected Files
frontend/components/ui/logo-carousel.tsx