Describe the bug
When using Obsidian with the official Quick font size adjustment setting enabled, pressing Ctrl + scrolling the mouse wheel triggers the shiki-highlighter plugin to repeatedly create new Shiki instances without disposing the old ones. The console continuously outputs warnings like [Shiki] xxx instances have been created..., and the instance count keeps growing, severely impacting performance and causing memory leaks.
To Reproduce
- Install and enable the
shiki-highlighter plugin.
- Go to Settings → Appearance → Font section, then enable "Quick font size adjustment".
- Open the developer tools (
Ctrl+Shift+I) and switch to the Console panel.
- Continuously zoom in/out (e.g., hold
Ctrl and scroll the mouse wheel 10 steps). The console will show the first warning: [Shiki] 10 instances have been created...; continue scrolling and you will see warnings at 20, 30, etc.
Expected behavior
- When the configuration changes, the existing Shiki instance should be reused (singleton pattern), or the old instance should be disposed before creating a new one.
- No warnings about accumulating instances should appear in the console.
Screenshots
Occurs on
Plugin version
0.7.4
Additional context
Relevant Logs (excerpt)
app.js:1 Obsidian Developer Console
plugin:shiki-highlighter:33 [Shiki] 10 instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call `highlighter.dispose()` to release unused instances.
Wi @ plugin:shiki-highlighter:33
Gi @ plugin:shiki-highlighter:33
await in Gi
Ki @ plugin:shiki-highlighter:33
i @ plugin:shiki-highlighter:33
loadShiki @ plugin:shiki-highlighter:944
await in loadShiki
load @ plugin:shiki-highlighter:944
await in load
reloadHighlighter @ plugin:shiki-highlighter:945
await in reloadHighlighter
eval @ plugin:shiki-highlighter:945
(匿名) @ app.js:1
(匿名) @ app.js:1
(匿名) @ app.js:1
(匿名) @ app.js:1
e.onConfigChanged @ app.js:1
(匿名) @ app.js:1
(匿名) @ app.js:1
(匿名) @ app.js:1
t.setConfig @ app.js:1
(匿名) @ app.js:1
Note: English is not my native language. This issue description was translated into English with the assistance of AI. Please let me know if anything is unclear or needs further clarification.
Describe the bug
When using Obsidian with the official
Quick font size adjustmentsetting enabled, pressingCtrl+ scrolling the mouse wheel triggers theshiki-highlighterplugin to repeatedly create new Shiki instances without disposing the old ones. The console continuously outputs warnings like[Shiki] xxx instances have been created..., and the instance count keeps growing, severely impacting performance and causing memory leaks.To Reproduce
shiki-highlighterplugin.Ctrl+Shift+I) and switch to the Console panel.Ctrland scroll the mouse wheel 10 steps). The console will show the first warning:[Shiki] 10 instances have been created...; continue scrolling and you will see warnings at 20, 30, etc.Expected behavior
Screenshots
Occurs on
Plugin version
0.7.4
Additional context
Relevant Logs (excerpt)
Note: English is not my native language. This issue description was translated into English with the assistance of AI. Please let me know if anything is unclear or needs further clarification.