Improve responsiveness by processing initial styles in a service destructor

Created on 28 May 2022, over 2 years ago
Updated 3 May 2023, over 1 year ago

Problem/Motivation

If processing very large or multiple images to multiple derivatives, or calling out to an offsite service like resmush.it via imageoptimize_api to further optimise images, the UI can block for a considerable time after the user clicks submit. This can be very noticeable when inserting a newly uploaded image or images via the media library.

Deferring processing to a queue is a great option, but requires additional setup to process the queue, especially if you don't want to just trigger full cron runs all the time.

Proposed resolution

Add an option to defer initial processing into a service destructor, to be run at the end of the current request. This is non-blocking.

  • Add a needs_destruction tag to the services.yml
  • ImageStylesWarmer should implement DestructableInterface
  • In ImageStylesWarmer::warmUp(), store the current loaded file in a class property
  • Move processing of initial derivatves to a destruct() method.

This could be controlled by a pair of radio buttons with appropriately worded labels, with the default setting preserving the existing blocking behavior.

Feature request
Status

Fixed

Version

1.0

Component

User interface

Created by

🇳🇿New Zealand john pitcairn

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024