nextcloud / nextcloud/files_pdfviewer

[Bug]: PDF viewer fails to load first time around in Safari

Open
#1,241 3 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage bug
Dominant language
JavaScript
Stars
108
Forks
61
Avg merge
2d 9h
Merged PRs (30d)
29

Description

⚠️ This issue respects the following points: ⚠️
Bug description

I get a blank window on Safari 18.6 – except for controls along the top – when clicking on a PDF in the Files app whenever its the first time in a new window. If I then close that viewer and click on the PDF again, it will load fine.

The console log is showing the error:

[Error] TypeError: Right side of assignment cannot be destructured
	Module Code (pdfjs.js:59)

which points to this initialization code:

const {
  AbortException,
  AnnotationEditorLayer,
  AnnotationEditorParamsType,
  AnnotationEditorType,
  AnnotationEditorUIManager,
  AnnotationLayer,
  AnnotationMode,
  build,
  CMapCompressionType,
  createValidAbsoluteUrl,
  DOMSVGFactory,
  FeatureTest,
  getDocument,
  getFilenameFromUrl,
  getPdfFilenameFromUrl,
  getXfaPageViewport,
  GlobalWorkerOptions,
  ImageKind,
  InvalidPDFException,
  isDataScheme,
  isPdfFile,
  MissingPDFException,
  noContextMenu,
  normalizeUnicode,
  OPS,
  PasswordResponses,
  PDFDataRangeTransport,
  PDFDateString,
  PDFWorker,
  PermissionFlag,
  PixelsPerInch,
  PromiseCapability,
  RenderingCancelledException,
  renderTextLayer,
  setLayerDimensions,
  shadow,
  UnexpectedResponseException,
  updateTextLayer,
  Util,
  VerbosityLevel,
  version,
  XfaLayer,
} = globalThis.pdfjsLib;

so I'm guessing that this is some async issue to do with loading.

Steps to reproduce
  1. Open a "Private" window (easiest way to get a fresh session)
  2. Go into Files app
  3. Click on any PDF
Expected behavior

The PDF loads properly first time.

Nextcloud Server version

31

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.3

Web server

Nginx

Database engine version

MySQL

Is this bug present after an update or on a fresh install?

None

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report
{
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "upgrade.disable-web": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "nextcloud.**NOPE**.com"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "31.0.7.1",
        "overwrite.cli.url": "http:\/\/nextcloud.**NOPE**.com",
        "installed": true,
        "overwritehost": "nextcloud.**NOPE**.com",
        "overwriteprotocol": "https",
        "maintenance": false,
        "maintenance_window_start": 1,
        "loglevel": 2,
        "opcache.memory_consumption": 256,
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "mail_sendmailmode": "smtp",
        "mysql.utf8mb4": true,
        "allow_user_to_change_display_name": false,
        "lost_password_link": "disabled",
        "oidc_login_client_id": "nextcloud",
        "oidc_login_client_secret": "8vV1oiyR6On3G0HmubFBGzpZ5Y3aGZgV",
        "oidc_login_provider_url": "https:\/\/sso.**NOPE**.com\/realms\/**NOPE**\/",
        "oidc_login_auto_redirect": true,
        "oidc_login_end_session_redirect": true,
        "oidc_login_logout_url": "https:\/\/nextcloud.**NOPE**.com\/apps\/oidc_login\/oidc",
        "oidc_login_use_id_token": false,
        "oidc_login_attributes": {
            "id": "preferred_username",
            "mail": "email",
            "name": "name",
            "groups": "realm_access_roles",
            "is_admin": "realm_access_roles_admin"
        },
        "oidc_login_default_group": "everyone",
        "oidc_login_use_external_storage": false,
        "oidc_login_scope": "profile email",
        "oidc_login_proxy_ldap": false,
        "oidc_login_disable_registration": false,
        "oidc_login_redir_fallback": false,
        "oidc_login_tls_verify": true,
        "oidc_create_groups": false,
        "oidc_login_webdav_enabled": false,
        "oidc_login_password_authentication": false,
        "oidc_login_public_key_caching_time": 86400,
        "oidc_login_min_time_between_jwks_requests": 10,
        "oidc_login_well_known_caching_time": 86400,
        "oidc_login_update_avatar": false,
        "oidc_login_code_challenge_method": "S256",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "GB",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "app_install_overwrite": []
    }
}
List of activated Apps
Enabled:
  - activity: 4.0.0
  - bruteforcesettings: 4.0.0
  - calendar: 5.3.8
  - circles: 31.0.0
  - cloud_federation_api: 1.14.0
  - comments: 1.21.0
  - contactsinteraction: 1.12.0
  - dashboard: 7.11.0
  - dav: 1.33.0
  - deck: 1.15.2
  - federatedfilesharing: 1.21.0
  - files: 2.3.1
  - files_downloadlimit: 4.0.0
  - files_pdfviewer: 4.0.0
  - files_reminders: 1.4.0
  - files_sharing: 1.23.1
  - files_trashbin: 1.21.0
  - files_versions: 1.24.0
  - firstrunwizard: 4.0.0
  - groupfolders: 19.1.3
  - logreader: 4.0.0
  - lookup_server_connector: 1.19.0
  - nextcloud_announcements: 3.0.0
  - notifications: 4.0.0
  - oauth2: 1.19.1
  - oidc_login: 3.2.2
  - password_policy: 3.0.0
  - polls: 8.1.4
  - privacy: 3.0.0
  - profile: 1.0.0
  - provisioning_api: 1.21.0
  - recommendations: 4.0.0
  - related_resources: 2.0.0
  - richdocuments: 8.7.3
  - serverinfo: 3.0.0
  - settings: 1.14.0
  - sharebymail: 1.21.0
  - spreed: 21.1.2
  - support: 3.0.0
  - survey_client: 3.0.0
  - systemtags: 1.21.1
  - text: 5.0.0
  - theming: 2.6.1
  - theming_customcss: 1.18.0
  - twofactor_backupcodes: 1.20.0
  - twofactor_totp: 13.0.0-dev.0
  - updatenotification: 1.21.0
  - user_status: 1.11.0
  - viewer: 4.0.0
  - weather_status: 1.11.0
  - webhook_listeners: 1.2.0
  - workflowengine: 2.13.0
Disabled:
  - admin_audit: 1.21.0
  - app_api: 5.0.2 (installed 5.0.2)
  - encryption: 2.19.0
  - federation: 1.21.0 (installed 1.21.0)
  - files_3dmodelviewer: 0.0.15 (installed 0.0.15)
  - files_external: 1.23.0
  - htmlviewer: 31.0.0 (installed 31.0.0)
  - photos: 4.0.0 (installed 4.0.0)
  - suspicious_login: 9.0.1
  - twofactor_nextcloud_notification: 5.0.0
  - user_ldap: 1.22.0
Nextcloud Signing status
No errors have been found.
Nextcloud Logs

Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure in a Safari 18.6 private window with the files_pdfviewer app, then inspect the initialization at pdfjs.js:59 and the surrounding PDF.js loading sequence. Done means a PDF loads on its first opening in a new window without the destructuring error, while subsequent openings continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.