test: mark where the time goes when a message opens

This commit is contained in:
Linus Rath
2026-10-22 22:04:28 +02:00
parent 33fc33910a
commit 42e89122bd
2 changed files with 13 additions and 1 deletions
+5 -1
View File
@@ -19,7 +19,7 @@ import { useContactsStore } from '../stores/contacts-store';
import { useLocaleStore } from '../stores/locale-store';
import { spacing, typography, type ThemePalette } from '../theme/tokens';
import { useColors, useResolvedTheme } from '../theme/colors';
import { perfEndAfterPaint } from '../lib/perf-marks';
import { perfEndAfterPaint, perfLap } from '../lib/perf-marks';
import type { RootStackParamList } from '../navigation/types';
type Nav = NativeStackNavigationProp<RootStackParamList>;
@@ -684,6 +684,9 @@ export default function EmailBodyView({
[prepared.isHtml, prepared.applyInversion, quoteLabels],
);
// Performance harness: how much of opening a message is the WebView.
React.useEffect(() => { perfLap('open-message', 'body-mounted'); }, []);
const onMessage = (e: WebViewMessageEvent) => {
const data = e.nativeEvent.data;
// The body reported its size: it is laid out (performance harness).
@@ -791,6 +794,7 @@ export default function EmailBodyView({
injectedJavaScript={injectedJs}
onMessage={onMessage}
onLoadEnd={() => {
perfLap('open-message', 'webview-loaded');
// A (re)load resets the page's zoom state to 1 — drop any host-side
// scroll locks so they can't go stale (e.g. cid images arriving
// reload the source mid-zoom).
+8
View File
@@ -46,6 +46,14 @@ export function perfEnd(name: string, detail?: Record<string, string | number |
perfMark(name, { ms: Date.now() - t0, ...detail });
}
/** Log how far into a running span a step got, without ending it. */
export function perfLap(name: string, lap: string): void {
if (!enabled) return;
const t0 = started.get(name);
if (t0 === undefined) return;
perfMark(`${name}:${lap}`, { ms: Date.now() - t0 });
}
/**
* End a span once the next frames are drawn: two animation frames after the
* state change that rendered the result, so the time includes commit and