Commit 50bcfb1
perf(android): cut cover placeholder cost and bound the infinite list window (#166)
* perf(android): halve cover placeholder cost on grid screens
Android cover tiles did two rounds of the same work. `BookCoverBlurHash`
stacked an expo-image BlurHash layer *and* a Jetpack Compose `Host` that
decoded the identical BlurHash again, so every tile paid for a ComposeView,
its own composition and an AndroidComposeView owner. A Perfetto capture of
a scripted Discover -> ranking scroll showed 68 `Compose:initializeView`,
155 `Compose:recompose` (161ms) and 97 per-tile ComposeView draws in a
single 8s scroll, plus 416ms of GC (worst pause 113ms) from the churn.
- Replace the Compose `ExpoUIView` with a plain `ExpoView` that draws the
bitmap itself, and memoise decoded placeholders in a 256-entry LRU
(~2MB) so re-mounted covers cost a cache lookup. Adds `android.os.Trace`
sections for future captures.
- Drop the redundant expo-image BlurHash layer.
- Rename the native size props to `decodeWidth`/`decodeHeight`: `width`
and `height` collide with React Native layout style names, so Yoga sized
the placeholder to 32x48dp (112x168px) instead of filling the tile. The
removed expo-image layer had been masking that bug.
- Unmount the placeholder once the cover is displayed; it was invisible but
still drawn every frame.
- Replace the per-cover RN `Animated` fade with expo-image's native
`transition`, removing one view and one Animated node per tile.
- Memoise `BookCoverGridItem` and change `onPress` to receive the book so
every grid can hoist a stable handler; activating one cover no longer
re-renders the whole list. All seven call sites migrated.
- Clip offscreen rows on the ranking list (`removeClippedSubviews`).
Measured on a OnePlus PLC110 (Android 16, 144Hz), release builds, three
alternating runs per side, medians:
ranking scroll p90 25.2ms -> 19.1ms, p99 38.7ms -> 29.7ms,
over-budget frames 148/202 -> 67/176, dropped 21 -> 11
discover scroll p50 7.99ms -> 7.56ms
cold scroll p90 15.4ms -> 12.3ms, draw slices 1972ms -> 1023ms
GC during scroll 416ms -> 0ms, JS thread CPU 873ms -> 463ms
Compose init 68 -> 3 per run
Remaining cost is outside the view layer: 64 cover decodes at 7.5ms each
(expo-image already downsamples to the view box on Android) and 492ms of
`dequeueBuffer` waits from buffer stuffing.
* perf(mobile): bound the all-novels list window
Scrolling the infinite novel grid retained RN's default ~21 screens of
rows and their cover bitmaps: peak RSS measured 1.28GB across 30s of
scrolling on a PLC110, which is a large LMK risk on smaller devices.
windowSize=11 cuts that to 1.02GB (3 runs, all below every baseline run)
and drops 154 -> 116 (fling) and 128 -> 110 (relentless) dropped frames,
with per-second throughput unchanged at 101-102fps median.
removeClippedSubviews, maxToRenderPerBatch and updateCellsBatchingPeriod
were measured on the same scenario and rejected: they tripled draw work
(6.4s -> 16.4s of draw slices) and added missed vsyncs.
* refactor(mobile): trim review noise and gate list clipping to Android
- removeClippedSubviews on the ranking grid was unconditional, unlike the
four other lists in this app; on iOS it is known to blank out cells in
multi-column lists, so it now matches the existing Android-only gate.
- The same "module scope keeps the handler identity stable" paragraph was
copy-pasted above five hoisted navigation helpers; the reason belongs
once, on BookCoverGridItem's memo, and that comment already says it.
- Dropped comments that narrate the previous implementation (Compose host,
the doubled expo-image placeholder layer, the Animated fade) since the
code no longer contains any of it, and deduplicated the decodeWidth /
decodeHeight warning down to the prop registration that needs it.
- Removed the zero-duration Trace marker on the BlurHash cache-hit path: it
existed only for an A/B measurement and ran on every placeholder render.
- shelf-screen's press handler shadowed the outer `book`; renamed the
parameter.
* fix(ios): register secondary screen scroll owners
---------
Co-authored-by: Kanscape <Kanscape@celia.sh>1 parent 395859a commit 50bcfb1
15 files changed
Lines changed: 346 additions & 297 deletions
File tree
- apps/mobile
- modules/novella-ui
- android/src/main/java/sh/celia/novella/modules/novellaui
- src
- src
- components
- screens
Lines changed: 108 additions & 58 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
15 | 12 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
45 | 60 | | |
46 | | - | |
47 | | - | |
| 61 | + | |
| 62 | + | |
48 | 63 | | |
49 | 64 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| |||
Lines changed: 7 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
| 2 | + | |
4 | 3 | | |
5 | | - | |
| 4 | + | |
6 | 5 | | |
7 | | - | |
8 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
Lines changed: 6 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | 1 | | |
5 | 2 | | |
6 | 3 | | |
| |||
13 | 10 | | |
14 | 11 | | |
15 | 12 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
32 | 19 | | |
33 | 20 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
44 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| |||
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
75 | | - | |
| 81 | + | |
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
| |||
127 | 133 | | |
128 | 134 | | |
129 | 135 | | |
130 | | - | |
| 136 | + | |
131 | 137 | | |
132 | 138 | | |
133 | 139 | | |
| |||
0 commit comments