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) #164

Merged
merged 129 commits into from
Nov 30, 2022
Merged

Backoff retry failed images (#126) #164

merged 129 commits into from
Nov 30, 2022

Conversation

skazkiful
Copy link
Contributor

@skazkiful skazkiful commented Oct 7, 2022

Resolves #126

Synopsis

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

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

Solution

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

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

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

Checklist

  • Created PR:
    • In draft mode
    • Name contains issue reference
    • Has type and k:: labels applied
  • Before review:
    • Documentation is updated (if required)
    • Tests are updated (if required)
    • Changes conform code style
    • CHANGELOG entry is added (if required)
    • FCM (final commit message) is posted or updated
    • Draft mode is removed
  • Review is completed and changes are approved
    • FCM (final commit message) is approved
  • Before merge:
    • Milestone is set
    • PR's name and description are correct and up-to-date
    • All temporary labels are removed

@skazkiful skazkiful added enhancement Improvement of existing features or bugfix k::UI/UX UI (user interface) and UX (user experience) changes labels Oct 7, 2022
@skazkiful skazkiful added this to the 0.1.0-alpha.7 milestone Oct 7, 2022
@skazkiful skazkiful self-assigned this Oct 7, 2022
@skazkiful
Copy link
Contributor Author

@SleepySquash e2e тест ломается на ci, в обсуждали, что если понадобятся для него дополнительные приседания - не делать его, предлагаю отправить на проверку задачу, если посмотрите и решите что тест того не стоит или как-то по другому его можно сделать - переделаю или удалю его

@skazkiful
Copy link
Contributor Author

skazkiful commented Oct 11, 2022

FCM

Implement backoff images re-fetching (#164, #126)

- 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

@skazkiful skazkiful marked this pull request as ready for review October 11, 2022 21:17
@SleepySquash SleepySquash requested review from krida2000 and removed request for SleepySquash October 12, 2022 10:26
@skazkiful skazkiful marked this pull request as draft October 13, 2022 10:05
@skazkiful skazkiful removed the request for review from krida2000 October 13, 2022 10:07
lib/ui/page/home/widget/retry_image.dart Outdated Show resolved Hide resolved
lib/ui/page/home/widget/retry_image.dart Outdated Show resolved Hide resolved
lib/ui/page/home/widget/retry_image.dart Outdated Show resolved Hide resolved
lib/ui/page/home/widget/retry_image.dart Outdated Show resolved Hide resolved
test/e2e/steps/wait_until_attachment_fetched.dart Outdated Show resolved Hide resolved
@SleepySquash SleepySquash added the k::refactor Refactor changes of existing code label Nov 30, 2022
@SleepySquash SleepySquash enabled auto-merge (squash) November 30, 2022 11:05
@SleepySquash SleepySquash merged commit 2a3a528 into main Nov 30, 2022
@SleepySquash SleepySquash deleted the 126-retry-load-images branch November 30, 2022 11:13
github-actions bot added a commit that referenced this pull request 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::refactor Refactor changes of existing code k::UI/UX UI (user interface) and UX (user experience) changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backoff retry failed images
3 participants