Stop the cover preview from reloading layouts every cycle

PR 10849 was fine on public marketing URLs. On /edit-preference/whitelabel it was not. Chrome showed about 3.9 GB and CPU 111 on the Perfect Crew cover preview, against about 273 MB and CPU 29 on the build before 10849. The public pages still get one set of import()s. This page kept aborting them.

branch t3code/fix-marketing-preview-load-loop on top of 4b0b79a261, PR 10849 merged 3 commits, PR 10854

What went wrong

The appearance tab embeds the cover preview with [isNeedToRefreshColors]="true" and [previewBranding]="coverPreviewBranding". That getter built a new object on every change-detection cycle, even when the colors had not changed.

The preview treated a new object as a color change. It rebuilt sections and started import() for every missing layout. The generation token incremented at the start of each load, so the previous Promise.all was stale and never wrote the cache. PendingTasks.done() then scheduled another cycle. The cache stayed empty. The next cycle started the imports again.

Public / and /athletes pass sections once. They do not have this getter. That is why the leak showed up here and not on the marketing walk.

Commit 7309f6bd50: stop reloading layouts every cycle

2 files, +138 −21

What changed

  • coverPreviewBranding keeps the last object when the color, logo, and text fields are the same. Angular then sees a stable input.
  • The preview only treats branding as changed when those field values change, not when the object identity changes.
  • A resolve with the same layout list and page colors used to skip the data copy. That hid published heading and image updates on white-label home. A later commit rebuilds when the sections input changes.
  • Overlapping loads wait on one in-flight Promise.all. The generation token still drops a load after destroy. It no longer increments at the start of every resolve.

A real color edit still rebuilds. Switching desktop and mobile still rebuilds inputs. Destroy still aborts. What died is the empty-cache spin.

Commit 8dda6fb483: keep published copy updates, and do not load after destroy

Astra's review of this PR was right about two things. The resolve key does not include section payload. White-label home shows the cached cover, then refreshPublishedCoverPage swaps coverPageData. Same layout list meant the new headlines stayed off the screen. The waiter after an in-flight load could also start another import() after destroy.

  • When the sections input changes, resolveSectionsOnce always copies item.data again. Cached layout classes stay. The import gate is unchanged.
  • A destroyed flag is checked before the await, after the await, and before markForCheck.

How I would check it

Use a creator account on its white-label site. Do not publish. Chrome task manager is the memory check.

CheckWhat I expect
Open /edit-preference/whitelabel, cover preview tab, wait a minute Tab memory stays near the pre-10849 tab, hundreds of MB, not multiple GB. CPU settles.
Change a palette color The embed still recolors. It does not reload the same layout files in a loop.
Public /, /athletes, comparison Same sections as before. Unused layouts still off the wire. This PR does not undo 10849.

Verification checklist

Keep Chrome task manager open next to the tab. Do not publish. Checks are saved in this browser.

0 of 0 checked

High The appearance tab does not climb

Medium Real edits still preview