Skip to content

fix: stop background-tab feed loading, and show a deleted comment's replies on a phone - #323

Merged
therealsama merged 3 commits into
mainfrom
fix/background-feed-loading-and-phone-deleted-comments
Nov 4, 2026
Merged

therealsama merged 3 commits into
mainfrom
fix/background-feed-loading-and-phone-deleted-comments

Conversation

@therealsama

@therealsama therealsama commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes two bugs and a small performance issue.

Bug fixes

  • In a background tab, the feed kept loading page after page. The list loads the next page when its end-of-list marker is reported in view and nothing is loading. That report comes from the browser's intersection observer, which doesn't run while the page isn't drawn, but network requests still finish. So each page that landed turned loading back off and the list loaded again. In Chromium, scrolling to the bottom of the Top feed and switching tabs while the next page loaded fetched 22 more pages in 40 seconds: 20 to 638 cards, a page 49,000px tall, the scroll position unchanged. It stopped when the tab came back. Left alone it goes on to the feed's 365-day limit, or to the end of a domain's or user's results, since those pages share the list. With the tab in front, one scroll to the bottom loaded two pages for the same reason. The list now measures the marker again before each load and skips the load when the marker is more than the 200px preload margin below the viewport. In the same test, the background tab loaded only the page already in flight. One scroll to the bottom now loads one page, and each further scroll still loads the next. The check measures against the layout viewport, the one the observer uses, through the root element's clientHeight. On a zoomed-in iPad, which shows this list when a trackpad or mouse is connected, window.innerHeight is only the part on screen: measuring against it would skip loads the observer had asked for, and the list would stop loading.
  • On a phone, a deleted comment hid its replies. The full-screen comment showed only "Comment deleted" for any comment with no author and no text. The desktop page shows the same comment under a [deleted] byline, with its parent and story links and its replies. Tapping "parent" on reply 50343707 led to that dead end for 50343637. The phone now shows the dead end only when the comment has no replies and none are still loading. Otherwise it renders the comment as the desktop page does.

Performance

  • useItemWithComments parsed the cached thread on every render, though the read only seeds the initial state. Over five phone swipes with the CPU slowed 4×, those reads parsed 3.3 million characters, about 18ms in total. All item-cache reads in that test went from 152 to 20. It now reads the cache once, in a state initializer.

Known limitations

  • A deleted comment with no replies still gets the dead end, without parent or story links.
  • With one page per trip to the bottom, preloading now comes only from the 200px margin.

@therealsama
therealsama force-pushed the fix/background-feed-loading-and-phone-deleted-comments branch from 8998b1c to ed54679 Compare November 4, 2026 11:58
@therealsama therealsama changed the title fix: stop background-tab feed loading, and show the right comments on a phone fix: stop background-tab feed loading, and show a deleted comment's replies on a phone Nov 4, 2026
The list loaded the next page whenever its end-of-list marker was
reported in view and nothing was loading. That report only changes when
the browser's intersection observer runs, and it doesn't while the page
isn't drawn. Network requests still finish, so in a background tab each
page that landed turned `loading` back off and the list loaded again.

In Chromium, scrolling to the bottom of the Top feed and switching tabs
while the next page loaded went on to fetch 22 more pages in 40 seconds,
20 to 638 cards, with the scroll position unchanged. It stops only at
the feed's 365-day limit, or the end of a domain's or user's results,
or when the tab comes back. With the tab in front, one scroll to the
bottom loaded two pages, as the check ran before the browser reported
the marker's new position.

The list now measures the marker again before each load and skips it
when the marker is more than the preload margin below the viewport. A
background tab loads only the page already in flight, and one scroll to
the bottom loads one page.

The check uses the layout viewport, which the observer measures against,
through the root element's `clientHeight`. On a zoomed-in iPad, which
shows this list when a trackpad or mouse is connected, `innerHeight` is
only the part on screen: the check would skip a load the observer had
asked for, and the list would stop loading.
The phone's full-screen comment showed "Comment deleted", with nothing
else, for any comment with no author and no text, even one with
replies. The desktop page shows the same comment under a [deleted]
byline, with its parent and story links and its replies. Tapping
"parent" on reply 50343707 on a phone led to such a dead end for
comment 50343637.

The phone now shows the dead end only when the comment has no replies
and none are still loading. Otherwise it renders the comment as the
desktop page does.
useItemWithComments read the item cache in its body, which parses the
cached thread from localStorage on every render, though the result
only seeds the initial state. Over five swipes on a phone-speed CPU,
those reads parsed 3.3 million characters, about 18ms. It now reads
the cache once, in a state initializer.
@therealsama
therealsama force-pushed the fix/background-feed-loading-and-phone-deleted-comments branch from ed54679 to c4d2a0f Compare November 4, 2026 14:17
@therealsama
therealsama enabled auto-merge November 4, 2026 14:45
@therealsama
therealsama merged commit 8dca7a0 into main Nov 4, 2026
4 checks passed
@therealsama
therealsama deleted the fix/background-feed-loading-and-phone-deleted-comments branch November 4, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants