8000 Optimize Folder Icon Refresh to Improve Performance (#33) by Jessiii223 · Pull Request #67 · gfxholo/iconic · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Optimize Folder Icon Refresh to Improve Performance (#33) #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2025

Conversation

Jessiii223
Copy link
Contributor

Performance Optimization for Folder Operations

Issue

The plugin was experiencing performance issues (0.5-2 second delays) when opening/closing folders, particularly noticeable with folders containing many files. This was caused by:

  1. Icons being refreshed unnecessarily on both folder expand AND collapse
  2. No debouncing of refresh operations leading to potential rapid repeated updates

Solution

This PR optimizes the folder operations by:

  1. Only triggering icon refresh when expanding folders (not when collapsing)
  2. Adding debouncing to prevent multiple rapid refresh operations
  3. Ensuring proper cleanup of pending operations on unload

Implementation Details

  • Added a debounced refresh mechanism with a 100ms delay
  • Modified the mutation observer to only trigger on folder expand
  • Added cleanup for pending refresh operations
  • Added comprehensive comments explaining the optimization

Testing

The optimization significantly reduces lag when navigating folders:

  • Before: 0.5-2 second delays on folder operations
  • After: Immediate response on collapse, minimal delay on expand

Notes

Fixes #33 while maintaining all existing functionality.

@gfxholo gfxholo added the performance Laggy behavior caused by the plugin label Jan 23, 2025
@gfxholo
Copy link
Owner
gfxholo commented Jan 23, 2025

Oh wow, phenomenal work Jessie! These changes mesh really well at a casual glance :)

FileIconManager does have an over-refreshing problem, and this will probably do a lot to reduce that. I'll do some local testing when I get time and merge the fix as soon as possible.

@Jessiii223
8000 Copy link
Contributor Author

Thank you! I really love your plugin, glad I was able to help contribute! You've done really great work here!

@gfxholo
Copy link
Owner
gfxholo commented Jan 23, 2025

Huge thanks for your support! 💚

Okay, there's a massive improvement in response speed, testing this on a folder with 3000+ items. Still a small delay on the expand like you said, but that's an issue with the core refresh loop (it'll need a rework sometime).

Hit me with a few style changes and this should be ready to merge:

  • Keep the constructor as the top function, moving debouncedRefresh() to below refreshChildIcons()
  • Specify a void return type for debouncedRefresh()
  • Trim any tabs from the blank line in debouncedRefresh()
  • Omit the public modifier from unload()
  • Squash everything into one commit (use a force push for this)

@Jessiii223
Copy link
Contributor Author

@gfxholo I think I made all of the changes requested. I'm not super confident with Git so let me know if anything seems wrong.

@gfxholo gfxholo merged commit e547f94 into gfxholo:main Jan 25, 2025
@gfxholo
Copy link
Owner
gfxholo commented Jan 25, 2025

@gfxholo I think I made all of the changes requested. I'm not super confident with Git so let me know if anything seems wrong.

You did it perfectly, thank you so much!

I've never actually handled a pull request before, so this was really good practice for future contributions too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Laggy behavior caused by the plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Significant lag when opening or collapsing folders.
2 participants
0