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

Images upload from web page is slow because two previews are generated instead of once #16963

Closed
phpbg opened this issue Sep 1, 2019 · 7 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug

Comments

@phpbg
Copy link
Contributor

phpbg commented Sep 1, 2019

Steps to reproduce

  1. Open you files within a web browser
  2. Create an empty dir
  3. Open browser dev tool and watch network requests
  4. Upload a single jpeg picture inside
  5. Look for preview network requests, and check on the server side /var/nextcloud/data/appdata_*/preview/

Expected behaviour

There should be only one preview file on the server side

Actual behaviour

On the server side, two preview files are generated:
* 256-256-crop.jpg
* 5984-3376-max.jpg
When you upload a file from a web browser, you are in the file list, therefore only one small preview is required.
The bigger one is not (yet) required, and should either not be generated, or delayed for future generation.
This yields to very slow file upload, and if you upload many pictures, it will flood your server (the preview request takes around 10s on a dedicated i3-4020Y CPU @ 1.50GHz 4gb ram).

Server configuration

Operating system: ubuntu 18.04

Web server: apache 2.4 with fpm configuration

Database: mariadb 10.1

PHP version: 7.2

Nextcloud version: 16.0.4

Updated from an older Nextcloud/ownCloud or fresh install: Updated from 16.0.2, then 16.0.3

Where did you install Nextcloud from: official nextcloud release from github

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
Enabled:
  - accessibility: 1.2.0
  - bruteforcesettings: 1.4.0
  - calendar: 1.7.0
  - cloud_federation_api: 0.2.0
  - contacts: 3.1.3
  - dav: 1.9.2
  - federatedfilesharing: 1.6.0
  - files: 1.11.0
  - files_pdfviewer: 1.5.0
  - files_sharing: 1.8.0
  - files_trashbin: 1.6.0
  - files_videoplayer: 1.5.0
  - firstrunwizard: 2.5.0
  - gallery: 18.3.0
  - logreader: 2.1.0
  - lookup_server_connector: 1.4.0
  - nextcloud_announcements: 1.5.0
  - notifications: 2.4.1
  - oauth2: 1.4.2
  - password_policy: 1.6.0
  - provisioning_api: 1.6.0
  - serverinfo: 1.6.0
  - sharebymail: 1.6.0
  - spreed: 6.0.4
  - twofactor_backupcodes: 1.5.0
  - updatenotification: 1.6.0
  - viewer: 1.1.0
  - workflowengine: 1.6.0
Disabled:
  - activity
  - admin_audit
  - comments
  - encryption
  - federation
  - files_external
  - files_rightclick
  - files_texteditor
  - files_versions
  - privacy
  - recommendations
  - support
  - survey_client
  - systemtags
  - theming
  - user_ldap

Nextcloud configuration:

Config report
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***",
            "***REMOVED SENSITIVE VALUE***"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "16.0.4.1",
        "overwrite.cli.url": "http:\/\/nextcloud.home\/nextcloud",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "mysql.utf8mb4": true,
        "maintenance": false,
        "mail_smtpmode": "smtp",
        "mail_smtpsecure": "ssl",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "PLAIN",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "filelocking.enabled": true,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "timeout": 0
        },
        "loglevel": 2,
        "preview_max_x": "",
        "preview_max_xxx": ""
    }
}

Are you using external storage, if yes which one: cifs

Are you using encryption: no

Are you using an external user-backend, if yes which one: no

Client configuration

Browser: Chromium 76

Operating system: Ubuntu 18.04

Logs

Web server error log

Web server error log
No error

Nextcloud log (data/nextcloud.log)

Nextcloud log
There used to be no specific error, but now each time I run this test I'm getting this:
{"reqId":"jORNvCe5vsLfzesRF29X","level":3,"time":"2019-09-01T19:29:09+00:00","remoteAddr":"*","user":"*","app":"PHP","method":"GET","url":"/index.php/core/preview?fileId=15389&c=4c18cd61c7749f947a046309c38e454b&x=225&y=225&forceIcon=0","message":"imagecreatetruecolor(): Invalid image dimensions at /var/www/nextcloud/lib/private/legacy/image.php#880","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/76.0.3809.100 Chrome/76.0.3809.100 Safari/537.36","version":"16.0.4.1","id":"5d6c1cd7d9d6f"}
{"reqId":"jORNvCe5vsLfzesRF29X","level":3,"time":"2019-09-01T19:29:09+00:00","remoteAddr":"*","user":"*","app":"core","method":"GET","url":"/index.php/core/preview?fileId=15389&c=4c18cd61c7749f947a046309c38e454b&x=225&y=225&forceIcon=0","message":"OC_Image::preciseResize(): Error creating true color image","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/76.0.3809.100 Chrome/76.0.3809.100 Safari/537.36","version":"16.0.4.1","id":"5d6c1cd7d9d2b"}
{"reqId":"jORNvCe5vsLfzesRF29X","level":3,"time":"2019-09-01T19:29:09+00:00","remoteAddr":"*","user":"*","app":"PHP","method":"GET","url":"/index.php/core/preview?fileId=15389&c=4c18cd61c7749f947a046309c38e454b&x=225&y=225&forceIcon=0","message":"imagedestroy() expects parameter 1 to be resource, boolean given at /var/www/nextcloud/lib/private/legacy/image.php#884","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/76.0.3809.100 Chrome/76.0.3809.100 Safari/537.36","version":"16.0.4.1","id":"5d6c1cd7d9422"}

Browser log

Browser log
No specific error in JS console.
Request to preview looks like: `https://*****/index.php/core/preview?fileId=15389&c=4c18cd61c7749f947a046309c38e454b&x=225&y=225&forceIcon=0`
@phpbg phpbg added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Sep 1, 2019
@phpbg
Copy link
Contributor Author

phpbg commented Sep 1, 2019

By the way this seems to be a bug:

imagedestroy($process);

if ($process == false) {
	...
	imagedestroy($process); <-- $process is a boolean here...
	...
}

and here too:

imagedestroy($process);

@kesselb
Copy link
Contributor

kesselb commented Sep 1, 2019

Looks good to me. Mind to create a pull request with your changes?

"preview_max_x": "",

Mind to have a look at this? This could be the reason for imagecreatetruecolor(): Invalid image dimensions.

@phpbg
Copy link
Contributor Author

phpbg commented Sep 1, 2019

MMMhhhh ok, it seems I played a bit with config and issued those ugly things:

#Don't do this
php occ config:system:set preview_max_x
php occ config:system:set preview_max_xxx

I removed those ugly config params, and have no more errors in nextcloud logs.
I'll try a PR for the imagedestroy(false)

In the end, standard nextcloud config, no errors, but two previews generated instead of only one...

phpbg added a commit to phpbg/server that referenced this issue Sep 1, 2019
phpbg added a commit to phpbg/server that referenced this issue Sep 1, 2019
Signed-off-by: Samuel CHEMLA <chemla.samuel@gmail.com>
@phpbg phpbg changed the title Images upload from web page is slow because two previews are generated instead on once Images upload from web page is slow because two previews are generated instead of once Sep 2, 2019
rullzer added a commit that referenced this issue Sep 3, 2019
@rullzer rullzer mentioned this issue Sep 4, 2019
16 tasks
@phpbg
Copy link
Contributor Author

phpbg commented Sep 5, 2019

@szaimen
Copy link
Contributor

szaimen commented May 26, 2021

If I read correctly was this fixed with #16964 -> closing.

@szaimen szaimen closed this as completed May 26, 2021
@phpbg
Copy link
Contributor Author

phpbg commented May 26, 2021

Sorry @szaimen but #16964 was just about some cleanups

@phpbg phpbg reopened this May 26, 2021
@szaimen
Copy link
Contributor

szaimen commented May 26, 2021

After reading a bit more, I think this is not a bug but just the way how previews work in Nextcloud: the big thumbnail is for viewing it in the viewer app and the small for the list view. So not a bug but expected. -> closing.

@szaimen szaimen closed this as completed May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug
Projects
None yet
Development

No branches or pull requests

3 participants