Просмотр исходного кода

Reduce PDF.js maxCanvasPixels in Safari (#23781)

GitOrigin-RevId: 3b75d85bb4af33e4d4d40ee6f1dc9cf375f1435f
Alf Eaton 1 год назад
Родитель
Сommit
02cd5d2f2f

+ 2 - 1
services/web/frontend/js/features/pdf-preview/util/pdf-js-wrapper.ts

@@ -8,6 +8,7 @@ import {
   LinkTarget,
 } from 'pdfjs-dist/web/pdf_viewer.mjs'
 import 'pdfjs-dist/web/pdf_viewer.css'
+import browser from '@/features/source-editor/extensions/browser'
 
 const DEFAULT_RANGE_CHUNK_SIZE = 128 * 1024 // 128K chunks
 
@@ -36,7 +37,7 @@ export default class PDFJSWrapper {
       eventBus: this.eventBus,
       imageResourcesPath,
       linkService: this.linkService,
-      maxCanvasPixels: 8192 * 8192, // default is 4096 * 4096, increased for better resolution at high zoom levels
+      maxCanvasPixels: browser.safari ? 4096 * 4096 : 8192 * 8192, // default is 4096 * 4096, increased for better resolution at high zoom levels (but not in Safari, which struggles with large canvases)
       annotationMode: PDFJS.AnnotationMode.ENABLE, // enable annotations but not forms
       annotationEditorMode: PDFJS.AnnotationEditorType.DISABLE, // disable annotation editing
     })