Skip to content

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

@phpbg

Description

@phpbg

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`

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending check for reproducibility or if it fits our roadmapbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions