Commit 05048e4
authored
Fix memory leak: return early on image cache hit in MessageImageView (#93)
The .task block checked NSCache on cache hit but never returned, causing
getMediaContent to be called on every channel visit even for already-cached
images.
The fix always fetches raw data via the SDK (which hits its own disk cache
on repeat loads, avoiding network requests), then skips the expensive decode
step (toOrientedImage) when the NSImage is already in the NSCache.
Two caching layers serve different purposes:
- NSCache (checked in init): synchronously pre-populates `image` before the
view appears, preventing flicker on scroll/revisit. The image is already
on screen before .task runs its disk read.
- SDK media cache (getMediaContent): avoids network re-fetches. Always
called so `imageData` is populated for drag-and-drop, regardless of
whether the decoded NSImage is cached.
Fixes #891 parent 48b3c80 commit 05048e4
1 file changed
Lines changed: 14 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
104 | 113 | | |
105 | 114 | | |
106 | 115 | | |
| |||
0 commit comments