Skip to content

Introducing the maximum size preview - #14879

Merged
MorrisJobke merged 1 commit into
owncloud:masterfrom
oparoz:fix-preview-caching
Apr 7, 2015
Merged

MorrisJobke merged 1 commit into
owncloud:masterfrom
oparoz:fix-preview-caching

Conversation

@oparoz

@oparoz oparoz commented Mar 13, 2015

Copy link
Copy Markdown
Contributor

Replaces #13674

Fixes

The problem

You've just uploaded a 100MB TIFF file that you need to share with a restricted audience. Here is what currently happens once the file has been uploaded.

  • A 36x36 thumbnail is generated in 1 minute
  • Go to the Gallery, an album thumbnail might be generated in 1 minute
  • Go inside the album, another thumbnail will be generated in 1 minute
  • Click on the picture to get a full screen preview. 1 minute
  • Go back to the Files app and share the file
  • Client 1 visits the link. 1 minute to get the preview
  • Client 2 with a different screen resolution visits the link. 1 minute again

You're starting to get it. Every time a slightly different preview size is asked, a full conversion of that 100MB TIFF to PNG is performed. This is highly inefficient.

Proposed solution

  • Enforce maximum preview dimensions in the config. They're currently set to null.
  • The first time we're asked to generate a preview we'll generate one of the maximum dimension indicated in the configuration and all future resizing requests will be done on that preview in order to not waste time converting the same large file over and over

Default size is 2048x2048
The maximum size preview is keeping the aspect ratio of the original and is not upscaled.
It's is immediately stored in the cache with a special max tag and size identifiers based on its real size.

Every time a preview of a different size is asked, we store it in the cache. This also speeds up operation at the cost of disk space.

This make a huge difference in libraries holding several large files, for people using apps such as the Gallery.

Recreated after the loss of #13582

@karlitschek

Copy link
Copy Markdown
Contributor

@georgehrke What is your opinion?

Comment thread lib/private/preview.php

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we maybe modify the constructor to expect some OCP\IConfig and if null is given fall back to \OC::$server->getConfig() (edit: and the same for logging)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Seems doable, but is it the right patch to modify the signature? Wouldn't it be better to introduce that in a PR which can be given as a reference to the change so that people can start modifying their code? cc @MorrisJobke @LukasReschke

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

People should never create a \OC\Preview instance directly and use getPreviewManager anyway.
(but removing all direct creations of \OC\Preview in core should definitely be done in a separate pr. (will take care))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, except that, sometimes, it's not possible to use it as PreviewManager is not yet a true replacement of \OC\Preview
See #12772 for what's missing

But if it's confirmed that the signature change should happen here, I'll do it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's the right approach, but will conflict greatly with #14857

Maybe you can wait, until that is done, since it is a major rework on the same file aswell ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds reasonable. I'll let you adjust the signature then and will update this PR when you're done.

@georgehrke

Copy link
Copy Markdown
Contributor

Code looks good to me otherwise

  • Add unit tests for newly introduced methods

Comment thread lib/private/preview.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will conflict with #14857

@oparoz

oparoz commented Mar 19, 2015

Copy link
Copy Markdown
Contributor Author

Since there were no newly introduced public methods, I just did an extensive preview size test.

I'm also forcing a resize since the image provider is not doing it's resizing job properly and since that's what people are going to use the most.

I've found that testing the file individually (using the bootstrap) will WIPE your admin's data.

Note: It's possible to tweak the preview size and get the test to fail, because of this bug: #14712

@oparoz

oparoz commented Apr 7, 2015

Copy link
Copy Markdown
Contributor Author

@georgehrke @MorrisJobke @PVince81 @DeepDiver1975
Could me merge this before the PR goes, once again, out of sync?

@oparoz

oparoz commented Apr 7, 2015

Copy link
Copy Markdown
Contributor Author

Maybe @icewind1991 and @jancborchardt want to test it as well since this benefits the Gallery apps.

Comment thread lib/private/preview.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use the interface please

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, thanks.

The first time we're asked to generate a preview we'll generate one of the maximum dimension indicated in the configuration and all future resizing requests will be done on that preview in order to not waste time converting the same file over and over.

One of the fixes required for #12465
@scrutinizer-notifier

Copy link
Copy Markdown

The inspection completed: 2 new issues, 6 updated code elements

@ghost

ghost commented Apr 7, 2015

Copy link
Copy Markdown

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/11279/
🚀 Test PASSed.🚀
chuck

@MorrisJobke

Copy link
Copy Markdown
Contributor

Tested and works 👍

@georgehrke

Copy link
Copy Markdown
Contributor

mentioned issues fixed, works 👍

MorrisJobke added a commit that referenced this pull request Apr 7, 2015
Introducing the maximum size preview
@MorrisJobke
MorrisJobke merged commit 6c327f8 into owncloud:master Apr 7, 2015
@oparoz
oparoz deleted the fix-preview-caching branch April 23, 2015 22:17
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants