From 343abb0a80d43a04f7b1923157bf497abd2f05ba Mon Sep 17 00:00:00 2001 From: Yusuf Suleman Date: Fri, 3 Apr 2026 22:54:36 -0500 Subject: [PATCH] perf: warm WebKit rendering pipeline with realistic HTML template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Empty HTML warmup only spun up the WebContent process. The first real article still paid ~3s for CSS parsing, font measurement, layout engine init, and compositing pipeline startup. Now ArticleRenderer.init loads the full ArticleHTMLBuilder template with sample content covering all styled elements (paragraphs, headings, blockquotes, code blocks). WebKit performs real rendering during app launch while the user is on Home/Fitness. By the time they open the first article, CSS is parsed, fonts are measured, and the pipeline is warm — the first article renders as fast as subsequent ones. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Reader/Views/ArticleWebView.swift | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ios/Platform/Platform/Features/Reader/Views/ArticleWebView.swift b/ios/Platform/Platform/Features/Reader/Views/ArticleWebView.swift index 977ffaf..900a508 100644 --- a/ios/Platform/Platform/Features/Reader/Views/ArticleWebView.swift +++ b/ios/Platform/Platform/Features/Reader/Views/ArticleWebView.swift @@ -18,8 +18,28 @@ final class ArticleRenderer { webView.backgroundColor = .clear webView.scrollView.isScrollEnabled = true - // Pre-warm: spin up WebContent process at app launch - webView.loadHTMLString("", baseURL: nil) + // Pre-warm with realistic content. An empty + // only warms the WebContent process. Loading the real CSS template with + // sample text forces WebKit to also parse CSS, load/measure system fonts, + // initialize the layout engine, and spin up the compositing pipeline. + // This shifts the ~3s first-render cost to app launch (background) so the + // first article open doesn't stall. + webView.loadHTMLString(ArticleHTMLBuilder.build( + title: "Warming up", + url: nil, + feedName: "Reader", + author: "System", + timeAgo: "now", + readingTime: "1 min", + body: """ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. \ + Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+

Section heading

+

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.

+
Quoted text for blockquote styling.
+
code { display: block; }
+ """ + ), baseURL: nil) } }