Qbject / obsidian-canvas-link-optimizer

An Obsidian plugin that optimizes canvas links by displaying a page thumbnail.
MIT License
16 stars 1 forks source link

Thumbnails Caches for Internal Images As Well? #3

Open yuboWw opened 1 week ago

yuboWw commented 1 week ago

I just came across this plugin while looking for enhancement plugins for Canvas. I think this is a fantastic creation to improve performance of Canvas. But, I do think, just in general, images are more common than transcluded webpages. I'm not familiar with the technicality in that regard, but i'm curious to know:

I also proposed this idea as a feature request on the official forum

@Qbject thanks for this, yubo

Qbject commented 6 days ago

@yuboWw thanks for the feedback, I appreciate it!

I've noticed some performance issues related to images, but in my canvases, there's about 10 times fewer images than web embeds, so I didn't pay much attention to this. But this seems to be a common issue, so I took a look into it.

The current web embeds approach would need a considerable rework to make it work with images (it's doable though), so I've come up with a much simpler idea - just hide images while zoomed out (like other node types).

Here's my quick dirty solution to this:

const nodes = app.workspace.getActiveFileView().canvas.nodes.values();
for(const node of nodes){
    if(node.getData().type === "file"){
        delete node.__proto__.updateBreakpoint;
        node.updateBreakpoint();
    }
}

Just open any canvas with at least a single image in it and run this code in the developer's console (ctrl+shift+I -> Console). Once done, all the media on all canvases should automatically unload until you restart Obsidian.

Please let me know what you think. If this works for you, I can make this into a proper separate plugin or add as a feature to this one.

P.S. From my observations, the easiest way to kill canvas performance is by PDF files. So make sure you don't include them directly into a canvas.

yuboWw commented 5 days ago

@yuboWw thanks for the feedback, I appreciate it!

I've noticed some performance issues related to images, but in my canvases, there's about 10 times fewer images than web embeds, so I didn't pay much attention to this. But this seems to be a common issue, so I took a look into it.

The current web embeds approach would need a considerable rework to make it work with images (it's doable though), so I've come up with a much simpler idea - just hide images while zoomed out (like other node types).

Here's my quick dirty solution to this:


const nodes = app.workspace.getActiveFileView().canvas.nodes.values();

for(const node of nodes){

    if(node.getData().type === "file"){

        delete node.__proto__.updateBreakpoint;

        node.updateBreakpoint();

    }

}

Just open any canvas with at least a single image in it and run this code in the developer's console (ctrl+shift+I -> Console). Once done, all the media on all canvases should automatically unload until you restart Obsidian.

Please let me know what you think. If this works for you, I can make this into a proper separate plugin or add as a feature to this one.

P.S. From my observations, the easiest way to kill canvas performance is by PDF files. So make sure you don't include them directly into a canvas.

@Qbject

thanks for your efforts!

i tried the temporary solution, it works, the lagging issue is gone. this is nice.

because all images are unloaded, when zoomed out, it's not showing a birds-eye-view of the canvas and how the images are arranged to show their content-wise relationship and abstract content, which is the intuitive/complete solution to this issue.

as you mentioned, i'd also imagine this is a common problem to all canvas users, especially for visual art related projects where there are many images on the canvas, as it is my case, but could also for anything that's visual heavy

i'm so glad and i very much appreciate that you offered to integrate this into the webpages plugin you made or to make it into a standalone one; either case, i would love to follow closely and hear from the progress in that pursuit. pls lmk!

thank you so much for your efforts to the community!

Qbject commented 2 days ago

@yuboWw

I'm back with the news. So, I started to develop a tool for images downscaling and this got me into a quite a journey. Long story short:

As appears, images themselves don't have a significant impact on performance (my laptop could easily render 432 images 3840x2160px). Instead I found a few bugs in Obsidian that were ruining the canvas performance. I've already notified the developers about my discovery, so hopefully we'll eventually get an update resolving this.

Also I've developed own patch for these issues in form of a plugin. Feel free to install it (it's not in the plugin library, so you'll need to do it manually) and let me know if it works.

P.S. I've released the new update for canvas-link-optimizer plugin making link thumbnails visible at any zoom level, so if you're using it, you may want to update.