typst-preview icon indicating copy to clipboard operation
typst-preview copied to clipboard

[Partial Rendering] Content on preview disappears

Open lnatero opened this issue 2 years ago • 2 comments

Describe the bug When Partial Rendering is set to True at certain zoom levels the content disappears, if I zoom in a lot everything within the view window appears, but is practically unusable. I haven't looked into the code of the extension yet, but maybe it could be fixed if partial rendering was set on a per page basis, and not being determined by the view window.

To Reproduce Steps to reproduce the behavior (Library test):

  1. Open the Preview on the VS Code side window.
  2. Set Partal Rendering on the Typst-preview settings to True.
  3. Move through a document through the preview at different zoom levels.

Expected behavior Content shouldn't disappear while panning on the file preview

VSCode version(Help -> About):

Version: 1.82.0 (user setup)
Commit: 8b617bd08fd9e3fc94d14adb8d358b56e3f72314
Date: 2023-09-06T22:07:07.438Z
Electron: 25.8.0
ElectronBuildId: 23503258
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.22621

typst-preview extension version: v0.7.5

Logs:

typst-preview server log(Output Panel -> typst-preview):

[2023-09-10T21:13:38Z INFO  typst_preview] Arguments: CliArguments {
        font_paths: [],
        root: Some(
            "d:\\Users\\Lucas\\OneDriveUC\\Documents\\.uc\\2023\\2do\\Imágenes Biomédicas",
        ),
        data_plane_host: "127.0.0.1:0",
        control_plane_host: "127.0.0.1:0",
        static_file_host: "127.0.0.1:0",
        dont_open_in_browser: true,
        enable_partial_rendering: false,
        input: "d:\\Users\\Lucas\\OneDriveUC\\Documents\\.uc\\2023\\2do\\Imágenes Biomédicas\\Tareas\\T2\\typst\\main.typ",
    }
[2023-09-10T21:13:38Z INFO  typst_ts_compiler::service::diag] \Tareas\T2\typst\main.typ: compiling ...
[2023-09-10T21:13:38Z INFO  typst_preview] Data plane server listening on: 127.0.0.1:59901
[2023-09-10T21:13:38Z INFO  typst_preview] Control plane server listening on: 127.0.0.1:59902
[2023-09-10T21:13:38Z INFO  typst_preview] Static file server listening on: 127.0.0.1:59903
[2023-09-10T21:13:38Z INFO  typst_preview] Peer address: 127.0.0.1:59904
[2023-09-10T21:13:38Z INFO  typst_preview] New WebSocket connection: 127.0.0.1:59904
[2023-09-10T21:13:38Z DEBUG typst_preview::actor::editor] EditorActor: received message from editor: SyncMemoryFiles []
[2023-09-10T21:13:39Z INFO  typst_ts_compiler::service::diag] \Tareas\T2\typst\main.typ: Compilation succeeded in 503.5993ms
[2023-09-10T21:13:39Z DEBUG typst_preview::actor::typst] TypstActor: waiting for message
[2023-09-10T21:13:39Z DEBUG typst_preview::actor::typst] TypstActor: processing SYNC memory files: []
[2023-09-10T21:13:39Z INFO  typst_ts_compiler::service::diag] \Tareas\T2\typst\main.typ: compiling ...
[2023-09-10T21:13:39Z INFO  typst_ts_compiler::service::diag] \Tareas\T2\typst\main.typ: Compilation succeeded in 3.3134ms
[2023-09-10T21:13:39Z DEBUG typst_preview::actor::typst] TypstActor: waiting for message
[2023-09-10T21:13:40Z INFO  typst_preview] Peer address: 127.0.0.1:59905
[2023-09-10T21:13:40Z INFO  typst_preview] New WebSocket connection: 127.0.0.1:59905
[2023-09-10T21:13:40Z DEBUG typst_preview::actor::render] RenderActor: waiting for message
[2023-09-10T21:13:40Z DEBUG typst_preview::actor::webview] WebviewActor: received message from websocket: Ok(Text("current"))
[2023-09-10T21:13:40Z DEBUG typst_preview::actor::render] RenderActor: has_full_render: true
[2023-09-10T21:13:40Z INFO  typst_ts_svg_exporter::frontend::incremental] svg render time (incremental bin): 19.0569ms
[2023-09-10T21:13:40Z DEBUG typst_preview::actor::render] RenderActor: waiting for message
[2023-09-10T21:13:40Z DEBUG typst_preview::actor::webview] WebviewActor: received svg from renderer
[2023-09-10T21:13:55Z INFO  typst_preview] Arguments: CliArguments {
        font_paths: [],
        root: Some(
            "d:\\Users\\Lucas\\OneDriveUC\\Documents\\.uc\\2023\\2do\\Imágenes Biomédicas",
        ),
        data_plane_host: "127.0.0.1:0",
        control_plane_host: "127.0.0.1:0",
        static_file_host: "127.0.0.1:0",
        dont_open_in_browser: true,
        enable_partial_rendering: true,
        input: "d:\\Users\\Lucas\\OneDriveUC\\Documents\\.uc\\2023\\2do\\Imágenes Biomédicas\\Tareas\\T2\\typst\\main.typ",
    }
[2023-09-10T21:13:55Z INFO  typst_ts_compiler::service::diag] \Tareas\T2\typst\main.typ: compiling ...
[2023-09-10T21:13:55Z INFO  typst_preview] Data plane server listening on: 127.0.0.1:59907
[2023-09-10T21:13:55Z INFO  typst_preview] Control plane server listening on: 127.0.0.1:59906
[2023-09-10T21:13:55Z INFO  typst_preview] Static file server listening on: 127.0.0.1:59908
[2023-09-10T21:13:55Z INFO  typst_preview] Peer address: 127.0.0.1:59909
[2023-09-10T21:13:55Z INFO  typst_preview] New WebSocket connection: 127.0.0.1:59909
[2023-09-10T21:13:55Z DEBUG typst_preview::actor::editor] EditorActor: received message from editor: SyncMemoryFiles []
[2023-09-10T21:13:56Z INFO  typst_ts_compiler::service::diag] \Tareas\T2\typst\main.typ: Compilation succeeded in 520.2066ms
[2023-09-10T21:13:56Z DEBUG typst_preview::actor::typst] TypstActor: waiting for message
[2023-09-10T21:13:56Z DEBUG typst_preview::actor::typst] TypstActor: processing SYNC memory files: []
[2023-09-10T21:13:56Z INFO  typst_ts_compiler::service::diag] \Tareas\T2\typst\main.typ: compiling ...
[2023-09-10T21:13:56Z INFO  typst_ts_compiler::service::diag] \Tareas\T2\typst\main.typ: Compilation succeeded in 4.1411ms
[2023-09-10T21:13:56Z DEBUG typst_preview::actor::typst] TypstActor: waiting for message
[2023-09-10T21:13:57Z INFO  typst_preview] Peer address: 127.0.0.1:59910
[2023-09-10T21:13:57Z INFO  typst_preview] New WebSocket connection: 127.0.0.1:59910
[2023-09-10T21:13:57Z DEBUG typst_preview::actor::render] RenderActor: waiting for message
[2023-09-10T21:13:57Z DEBUG typst_preview::actor::webview] WebviewActor: received message from websocket: Ok(Text("current"))
[2023-09-10T21:13:57Z DEBUG typst_preview::actor::render] RenderActor: has_full_render: true
[2023-09-10T21:13:57Z INFO  typst_ts_svg_exporter::frontend::incremental] svg render time (incremental bin): 20.8755ms
[2023-09-10T21:13:57Z DEBUG typst_preview::actor::render] RenderActor: waiting for message
[2023-09-10T21:13:57Z DEBUG typst_preview::actor::webview] WebviewActor: received svg from renderer

typst-preview client log(Help -> Toggle Developer Tools -> Console):

webviewElement.ts:512 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.
mountTo @ webviewElement.ts:512
console.ts:137 [Extension Host] Create new Loggly
console.ts:137 [Extension Host] GBVSC-AppsDataProvider:::General::init-flow: constructor
localProcessExtensionHost.ts:283 Extension Host
localProcessExtensionHost.ts:284 GBVSC-AppsDataProvider:::General::init-flow: constructor

console.ts:137 [Extension Host] GBVSC-Ext:::General::init-flow: activate
console.ts:137 [Extension Host] initialisation duration: 0.50
console.ts:137 [Extension Host] [INIT:DEBUG] extension.checkServerIsAlive
console.ts:137 [Extension Host] [INIT:DEBUG] appsDataPRovider.checkServerAlive null
localProcessExtensionHost.ts:283 Extension Host
localProcessExtensionHost.ts:284 GBVSC-Ext:::General::init-flow: activate

log.ts:441   ERR [Extension Host] GBVSC-AppsDataProvider:::General::callback-checkServerAlive: connect ECONNREFUSED 127.0.0.1:10101
console.ts:137 [Extension Host] GBVSC-AppsDataProvider:::General::callback-checkServerAlive: connect ECONNREFUSED 127.0.0.1:10101
m @ console.ts:137
console.ts:137 [Extension Host] [INIT:DEBUG] extension.checkServerIsAlive RESPONSE false undefined
log.ts:421  INFO [perf] Render performance baseline is 115ms
VM7:4 cloudMode inline:  false
vueMain.js:67 GB_SOURCE (cloudMode):  false
vueMain.js:68 GenieServerPanel started. Cloud-mode: false
vue.js:7533 Download the Vue Devtools extension for a better development experience:
https://github.com/vuejs/vue-devtools
vue.js:7542 You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html
log.ts:431  WARN Settings pattern "application.*" doesn't match any settings
console.ts:137 [Extension Host] GBVSC-Ext:::GBServerPanel::message-received: getUpdateGBStatus
console.ts:137 [Extension Host] SystemInfo:  Object
log.ts:441   ERR [Extension Host] (node:22112) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `Code --trace-deprecation ...` to show where the warning was created)
console.ts:137 [Extension Host] (node:22112) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `Code --trace-deprecation ...` to show where the warning was created)
m @ console.ts:137
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.julia.
Old grammar file: file:///c%3A/Users/Lucas/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/julia/syntaxes/julia.tmLanguage.json.
New grammar file: file:///c%3A/Users/Lucas/.vscode/extensions/julialang.language-julia-1.51.2/syntaxes/julia_vscode.json
register @ TMScopeRegistry.ts:46
semanticTokensProviderStyling.ts:108 Overlapping semantic tokens detected at lineNumber 40, column 1
warnOverlappingSemanticTokens @ semanticTokensProviderStyling.ts:108
semanticTokensProviderStyling.ts:115 Semantic token with invalid length detected at lineNumber 41, column 3
warnInvalidLengthSemanticTokens @ semanticTokensProviderStyling.ts:115
console.ts:137 [Extension Host] watch editor changes
console.ts:137 [Extension Host] getCliPath resolving c:\Users\Lucas\.vscode\extensions\mgt19937.typst-preview-0.7.5-win32-x64\out\typst-preview 
console.ts:137 [Extension Host] Watching d:\Users\Lucas\OneDriveUC\Documents\.uc\2023\2do\Imágenes Biomédicas\Tareas\T2\typst\main.typ for changes
console.ts:137 [Extension Host] [2023-09-10T21:13:38Z INFO  typst_preview] Data plane server listening on: 127.0.0.1:59901
[2023-09-10T21:13:38Z INFO  typst_preview] Control plane server listening on: 127.0.0.1:59902
[2023-09-10T21:13:38Z INFO  typst_preview] Static file server listening on: 127.0.0.1:59903

console.ts:137 [Extension Host] Launched server, data plane port:59901, control plane port:59902
webviewElement.ts:512 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.
mountTo @ webviewElement.ts:512
console.ts:137 [Extension Host] recv syncEditorChanges request
log.ts:431  WARN Settings pattern "application.*" doesn't match any settings
console.ts:137 [Extension Host] killed preview services
console.ts:137 [Extension Host] child process exited with code null
semanticTokensProviderStyling.ts:108 Overlapping semantic tokens detected at lineNumber 40, column 1
warnOverlappingSemanticTokens @ semanticTokensProviderStyling.ts:108
semanticTokensProviderStyling.ts:115 Semantic token with invalid length detected at lineNumber 41, column 3
warnInvalidLengthSemanticTokens @ semanticTokensProviderStyling.ts:115
console.ts:137 [Extension Host] watch editor changes
console.ts:137 [Extension Host] Watching d:\Users\Lucas\OneDriveUC\Documents\.uc\2023\2do\Imágenes Biomédicas\Tareas\T2\typst\main.typ for changes
console.ts:137 [Extension Host] [2023-09-10T21:13:55Z INFO  typst_preview] Data plane server listening on: 127.0.0.1:59907
[2023-09-10T21:13:55Z INFO  typst_preview] Control plane server listening on: 127.0.0.1:59906

console.ts:137 [Extension Host] Launched server, data plane port:59907, control plane port:59906
webviewElement.ts:512 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.
mountTo @ webviewElement.ts:512
console.ts:137 [Extension Host] [2023-09-10T21:13:55Z INFO  typst_preview] Static file server listening on: 127.0.0.1:59908
[2023-09-10T21:13:55Z INFO  typst_preview] Peer address: 127.0.0.1:59909

console.ts:137 [Extension Host] recv syncEditorChanges request
VM7:4937 plugin initialized, build info: Object
VM7:4886 WebSocket connection opened
VM7:4910 partial-rendering 4
VM7:4919 Experimental feature: partial rendering enabled
VM7:4910 diff-v1 4571196
VM7:641 render_in_window with partial rendering enabled 0.9473698382776219 -330.63207355889006 1818.950089493034 612.0009155273438 685.8957629129983
VM7:702 parse 15.50 ms, check-diff 54.60 ms, patch 88.20 ms, total 158.30 ms
VM7:641 render_in_window with partial rendering enabled 0.960754969430681 -335.30348433130763 1844.6495413069074 620.6477102522199 416.96765673291554
VM7:702 parse 0.00 ms, check-diff 1.10 ms, patch 8.00 ms, total 9.10 ms
VM7:641 render_in_window with partial rendering enabled 0.960754969430681 -335.30348433130763 1846.9553533251658 620.6477102522199 416.96765673291554
VM7:702 parse 0.00 ms, check-diff 0.20 ms, patch 6.60 ms, total 6.80 ms
VM7:641 render_in_window with partial rendering enabled 0.960754969430681 -335.30348433130763 1967.6261773940346 620.6477102522199 416.96765673291554
VM7:702 parse 0.00 ms, check-diff 0.20 ms, patch 0.20 ms, total 0.40 ms
VM7:641 render_in_window with partial rendering enabled 0.960754969430681 -335.30348433130763 2072.156321000084 620.6477102522199 416.96765673291554
...

I cut off the output log after these lines, but the rest is basically the last two lines repeating over and over.

lnatero avatar Sep 10 '23 21:09 lnatero

The log shows that the window is in left: -335px, top: 2072px and width: 620px, height: 416px

VM7:641 render_in_window with partial rendering enabled 0.960754969430681 -335.30348433130763 2072.156321000084 620.6477102522199 416.96765673291554

Since it is getting a negative left value through incorrect calculations, this can also affect top and result in wrong or overly large values. Then, it could then causes the preview to render outside the boundaries of the last page. However, I have been unable to reproduce the issue with a negative left value.

We are sorry that it does not work well. You can disable the partial rendering feature until you find it slow to preview your document.

Myriad-Dreamin avatar Sep 10 '23 22:09 Myriad-Dreamin

The root cause of this bug is figured out with some acrobatics: If your mouse stays at a position with negative x, the related event will not be captured by window.addEventListener('mousewheel'). However this (mouse event out of the window) is hard to handle.

We still cannot confirm a normal situation that the previewer let mouse stay at a position with negative x.

Myriad-Dreamin avatar Sep 20 '23 20:09 Myriad-Dreamin

Outdated.

Myriad-Dreamin avatar Jul 15 '24 02:07 Myriad-Dreamin