Skip to content

Conversation

@artonge
Copy link
Contributor

@artonge artonge commented Apr 22, 2025

1. feat(previews): Support in memory preview request
This allows callers to use the API without increasing the disk usage.

2. fix(blurhash): Use preview API to generate the previews
This allows to benefit from all the checks done by the API.
This also used the newly introduced cacheResult argument to limit disk usage.

@artonge artonge requested a review from a team as a code owner April 22, 2025 14:42
@artonge artonge requested review from come-nc, skjnldsv and yemkareems and removed request for a team April 22, 2025 14:42
@artonge artonge force-pushed the artonge/fix/use_preview_api_for_blurhash_generation branch 2 times, most recently from 548bfd7 to 952a6d3 Compare April 22, 2025 14:48
@artonge artonge changed the title fix: Use preview API to generate the previews fix(blurhash): Use preview API to generate the previews Apr 22, 2025
@artonge artonge requested a review from susnux April 22, 2025 14:49
@artonge artonge self-assigned this Apr 22, 2025
@artonge artonge added 3. to review Waiting for reviews feature: previews and thumbnails php Pull requests that update Php code bug enhancement labels Apr 22, 2025
@artonge artonge added this to the Nextcloud 32 milestone Apr 22, 2025
@artonge artonge force-pushed the artonge/fix/use_preview_api_for_blurhash_generation branch from 952a6d3 to 5e47143 Compare April 22, 2025 14:52
skjnldsv

This comment was marked as duplicate.

Copy link
Member

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment otherwise good!

@artonge artonge force-pushed the artonge/fix/use_preview_api_for_blurhash_generation branch 3 times, most recently from aae841b to 009932f Compare April 23, 2025 08:17
@come-nc
Copy link
Contributor

come-nc commented Apr 24, 2025

psalm:update-baseline needed

@miaulalala
Copy link
Contributor

/backport to stable31

@miaulalala
Copy link
Contributor

/backport to stable30

@miaulalala
Copy link
Contributor

/backport to stable29

@artonge artonge force-pushed the artonge/fix/use_preview_api_for_blurhash_generation branch from 009932f to 15d4fb2 Compare April 24, 2025 09:23
@susnux
Copy link
Contributor

susnux commented Apr 24, 2025

🧪 💥

  1. Test\Preview\GeneratorTest::testGetNewPreview
    Expectation failed for method name is "putContent" when invoked 1 time(s).
    Method was expected to be called 1 times, actually called 0 times.

@artonge artonge force-pushed the artonge/fix/use_preview_api_for_blurhash_generation branch from 15d4fb2 to 7a763b8 Compare April 24, 2025 12:27
@artonge artonge force-pushed the artonge/fix/use_preview_api_for_blurhash_generation branch 2 times, most recently from 544943b to 1753b2c Compare April 28, 2025 09:04
This allows callers to use the API without increasing the disk usage.

Example: blurhash generation, where we request a preview for all uploaded pictures, but don't want to necessarily store that preview.
Signed-off-by: Louis Chemineau <louis@chmn.me>
@artonge artonge force-pushed the artonge/fix/use_preview_api_for_blurhash_generation branch from 1753b2c to 024f756 Compare May 5, 2025 08:38
This allows to benefit from all the checks done by the preview API.
This also use the newly introduced `cacheResult` argument to limit disk usage.

Signed-off-by: Louis Chemineau <louis@chmn.me>
@artonge artonge force-pushed the artonge/fix/use_preview_api_for_blurhash_generation branch from 024f756 to 867be35 Compare May 5, 2025 09:13
@artonge artonge merged commit 1c518a2 into master May 6, 2025
210 of 214 checks passed
@artonge artonge deleted the artonge/fix/use_preview_api_for_blurhash_generation branch May 6, 2025 12:12
@skazi0
Copy link

skazi0 commented May 20, 2025

@artonge did you test this with 'enable_previews' => false ?

@artonge
Copy link
Contributor Author

artonge commented May 26, 2025

@artonge did you test this with 'enable_previews' => false ?

No. By reading the code, I assume this would skip blurhash generation. Which would be expected as blurhashes are a kind of preview.

@skazi0
Copy link

skazi0 commented May 27, 2025

@artonge did you test this with 'enable_previews' => false ?

No. By reading the code, I assume this would skip blurhash generation. Which would be expected as blurhashes are a kind of preview.

It doesn't generate blurhash but also logs:

"Exception":"OCP\\\\Files\\\\NotFoundException","Message":"Previews disabled","Code":0,
"Trace":[
{"file":"/var/www/nextcloud/lib/private/PreviewManager.php","line":157,"function":"throwIfPreviewsDisabled","class":"OC\\\\PreviewManager","type":"->"},
{"file":"/var/www/nextcloud/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php","line":71,"function":"getPreview","class":"OC\\\\PreviewManager","type":"->"},
{"file":"/var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php","line":68,"function":"handle","class":"OC\\\\Blurhash\\\\Listener\\\\GenerateBlurhashMetadata","type":"->"},
{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":220,"function":"__invoke","class":"OC\\\\EventDispatcher\\\\ServiceEventListener","type":"->"},
{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":56,"function":"callListeners","class":"Symfony\\\\Component\\\\EventDispatcher\\\\EventDispatcher","type":"->"},
{"file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":67,"function":"dispatch","class":"Symfony\\\\Component\\\\EventDispatcher\\\\EventDispatcher","type":"->"},
{"file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":79,"function":"dispatch","class":"OC\\\\EventDispatcher\\\\EventDispatcher","type":"->"},
{"file":"/var/www/nextcloud/lib/private/FilesMetadata/FilesMetadataManager.php","line":100,"function":"dispatchTyped","class":"OC\\\\EventDispatcher\\\\EventDispatcher","type":"->"},
{"file":"/var/www/nextcloud/lib/private/FilesMetadata/Job/UpdateSingleMetadata.php","line":43,"function":"refreshMetadata","class":"OC\\\\FilesMetadata\\\\FilesMetadataManager","type":"->"},
{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":61,"function":"run","class":"OC\\\\FilesMetadata\\\\Job\\\\UpdateSingleMetadata","type":"->"},
{"file":"/var/www/nextcloud/lib/public/BackgroundJob/QueuedJob.php","line":43,"function":"start","class":"OCP\\\\BackgroundJob\\\\Job","type":"->"},
{"file":"/var/www/nextcloud/lib/public/BackgroundJob/QueuedJob.php","line":29,"function":"start","class":"OCP\\\\BackgroundJob\\\\QueuedJob","type":"->"},
{"file":"/var/www/nextcloud/cron.php","line":170,"function":"execute","class":"OCP\\\\BackgroundJob\\\\QueuedJob","type":"->"}
]

IMO, this should be caught in GenerateBlurhashMetadata and ignored silently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews bug enhancement feature: previews and thumbnails php Pull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: cron.php crashes with memory exception in GenerateBlurhashMetadata.php because of large images

8 participants