Commit 929a4c1
feat(iOS): async image loading (#318)
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect -->
# Summary
Currently, all images on iOS are loaded in sync way. It fully blocks the
main thread and lets's say if we have a large image user has to wait
until this image is loaded.
The best approach for images is to always load them asynchronously. If
it's a local image -> it will be immediately loaded, it won't block the
main thread.
Additionally, I added the MediaAttachment class that implements the
abstract presentation of all attachments. So, if in the future if you
would like to add video/block image attachments, it would be easier to
extend from this class
## Test Plan
Test case 1:
1. Insert any image manually
Test case 2:
1. set the initial html like:
```
<html>
<p><img src="https://picsum.photos/id/1/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/2/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/3/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/4/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/5/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/6/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/7/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/8/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/9/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/10/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/11/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/12/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/13/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/14/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/15/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/16/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/17/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/18/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/19/200/200" width="200.000000" height="200.000000"/></p>
<p><img src="https://picsum.photos/id/20/200/200" width="200.000000" height="200.000000"/></p>
</html>
```
## Screenshots / Videos
### Before:
https://github.com/user-attachments/assets/f2a60c27-6d1a-4cd8-ba56-b44d2f9813be
### After:
https://github.com/user-attachments/assets/837aa5c9-aa35-49c7-ada2-a18b9b4116da
https://github.com/user-attachments/assets/1c32ccc6-fc5a-4caa-8225-5770122e502c
Include any visual proof that helps reviewers understand the change — UI
updates, bug reproduction or the result of the fix.
## Compatibility
| OS | Implemented |
| ------- | :---------: |
| iOS | ✅ |
| Android | ❌ |
---------
Co-authored-by: Mikołaj Szydłowski <9szydlowski9@gmail.com>1 parent d68eda4 commit 929a4c1
File tree
7 files changed
+141
-30
lines changed- ios
- attachments
- styles
7 files changed
+141
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1558 | 1558 | | |
1559 | 1559 | | |
1560 | 1560 | | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
1561 | 1588 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
| |||
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
118 | | - | |
| 120 | + | |
| 121 | + | |
119 | 122 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
129 | | - | |
| 132 | + | |
130 | 133 | | |
131 | 134 | | |
132 | | - | |
| 135 | + | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
138 | | - | |
| 141 | + | |
139 | 142 | | |
140 | 143 | | |
141 | 144 | | |
| |||
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | 160 | | |
0 commit comments