Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backoff retry failed images #126

Closed
SleepySquash opened this issue Sep 9, 2022 · 0 comments · Fixed by #164
Closed

Backoff retry failed images #126

SleepySquash opened this issue Sep 9, 2022 · 0 comments · Fixed by #164
Assignees
Labels
enhancement Improvement of existing features or bugfix k::UI/UX UI (user interface) and UX (user experience) changes
Milestone

Comments

@SleepySquash
Copy link
Contributor

SleepySquash commented Sep 9, 2022

Background

Изображение может вернуть любую ошибку - например, 404, если оно ещё не успело стать доступным на сервере.

Problem to solve

Если возвращается 404, то логично пробовать фетчить это изображение снова и снова по бэкофф алгоритму: сначала сразу же повторить запрос, затем через 500 миллисекунд, затем через 1 секунду, через 2, через 4, через 8 и так далее до какого-нибудь лимита (например, 32 секунды).

Possible solutions

Реализовать такой виджет, который будет ретраить получение неполученного изображения и, возможно, добавить возможность в будущем реализовать обработку для других ошибок.

В качестве примера можно посмотреть NetworkImageWithRetry от пакета flutter_image, который только под вебом не работает. Там в целом большой спектор ошибок обрабатывается, так что можно на него полагаться.

И стоит добавить такую штуку, как обработку именно 403-й ошибки. При получении 403-й ошибки нужно постучаться в RxChat.updateAttachments, чтобы получить новую ссылку на изображение/видео/файл.

@SleepySquash SleepySquash added enhancement Improvement of existing features or bugfix k::UI/UX UI (user interface) and UX (user experience) changes labels Sep 9, 2022
@SleepySquash SleepySquash added this to the 0.1.0-alpha.6 milestone Sep 9, 2022
@SleepySquash SleepySquash self-assigned this Sep 9, 2022
SleepySquash added a commit that referenced this issue Nov 30, 2022
- impl `RetryImage` widget re-fetching images
- impl naive caching of fetched images in `RetryImage`
- refactor code to use `RetryImage`s instead of `Image`s

Additionally:
- add mockable `PlatformUtils.dio` client
- fix `PreciseDateTime` adapter not storing microseconds

Co-authored-by: SleepySquash <nordnikita@icloud.com>
github-actions bot added a commit that referenced this issue Nov 30, 2022
- impl `RetryImage` widget re-fetching images
- impl naive caching of fetched images in `RetryImage`
- refactor code to use `RetryImage`s instead of `Image`s

Additionally:
- add mockable `PlatformUtils.dio` client
- fix `PreciseDateTime` adapter not storing microseconds

Co-authored-by: SleepySquash <nordnikita@icloud.com> 2a3a528
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix k::UI/UX UI (user interface) and UX (user experience) changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants