-
Notifications
You must be signed in to change notification settings - Fork 128
Consume File-Icons' element-icon service #281
Conversation
I can imagine how busy the Atom team are right now smoothing over bugs with the recent docked-views feature, as well as concentrating on fixing a pretty severe memory issue in the 1.18 beta. That being said, I really don't wanna come off sounding naggy or impatient... but could somebody give me an update on this? The rotten monkey-patches I wrote have been allowed to exist for exactly half-a-year now (at least in my timezone, which officially ticked over to June over an hour ago....) |
Thanks for the ping @Alhadis ... I'm going to get some 👀 on this 👍 |
Certainly! :D Which settings do you prefer I use when recording the timeline snapshot? I tend to get them all confused... 😞 Or is there another method you'd prefer I try to compare performance? |
Atom hanged when it was trying to save the recorded CPU profile, but that's what it usually does when I have my machine's root or home directory opened as a project... :( I managed to screen-cap the first profile, which was recording performance without this PR's changes in effect: I wish I knew how to read these things better. I'm still getting my head around what each graph means... |
@Alhadis if you can manage to save the profile, zip it up and email it to me at [email protected]? I believe saving the profile saves all the data and then I can fiddle with it on my end 👍 Thanks very much for helping out 🙇 |
I already tried, but it saved a blank file. :( As a matter of fact, this is what it always gives me whenever I try saving the CPU profile... :( |
You'll need to test on Atom 1.19.0-dev in order to get a non-blank profile. |
What @50Wliu said 😀 atom/atom#13767 |
Ugh... good grief. 😞 Should I profile the other packages while I'm running a HEAD-build of Atom v1.19, then...? |
Yes, please 🙏 |
Damn. Opening my user directory as an Atom project already shows how bad an issue this is... I'll e-mail you the first CPU profile I captured. It was done using dev-mode and no forked packages. Please let me know if you have difficulties extracting it: it's a 23.3 MBs file I had to 7-Zip. |
Profiling the other packages hasn't really revealed much of a difference. The hit to performance is mostly at startup, when |
Conflicts fixed, and the bitter taste of CoffeeScript washed away. |
Thanks @Alhadis 😀 I'm going to take a look at these next week when I'm on vacation and decompressing. |
The 'hell's this...?
Yet there were no lint errors locally: λ FuzzyFinder (file-icons): ./node_modules/.bin/standard .
λ FuzzyFinder (file-icons): |
Happy now, StandardJS?
/cc @nathansobo for review |
I appreciate your patience and dedication to making Atom better! |
Published as 1.7.0 and upgraded in atom/atom@d035e41. I should have asked you to write some basic tests for this. Would you be willing to do a follow up PR that adds some basic tests so we don't break this in the future? I'm going to hold off on the other 3 PRs until there's some test coverage in place. Thanks @Alhadis. |
Whoops, I had to revert the upgrade commit because there's an issue in with v8 snapshot generation, which you can see in this Circle build. I'll take a look. |
Okay, I fixed the snapshot issue in 2c1fe65 and re-upgraded to 1.7.1 in atom/atom@058a42f. Basically, you can't interact with the |
Oh, you guys are using
Ah, I never notice that. Sure thing! |
Yeah, maybe you already got to it, but we need to avoid eval-time references to the |
What about the complementary |
If it's not accessing any built-in modules it should be technically okay, but might be nice to make things consistent. Even better than a lazy getter would be dependency injection, but that's more work. |
Think I'll leave it for now. |
This PR applies to the
tabs
package what's been described inatom/tree-view#1146
for thetree-view
package. The PR's updated wording describes this scenario best, so I'll just copy+paste:I realised too late that your icon-service fulfils a different purpose from what our package needed. We wrote our own instead, which is built on a dubious but (currently) stable foundation of monkey-patches.
Opinions differ on the subject, but mine is that monkey-patching code you didn't write is bad, and should only be used as a last resort (DOM polyfills notwithstanding). Which is precisely what I've been forced to do to get dynamic icon-assignment working.
This needs to be fixed at a formal level, because:
Patches don't persist if File-Icons is deactivated and reactivated.
I've actually chosen not to fix this, because it would step outside the expected lifecycle of the package. E.g., when a user deactivates a package, they expect it to leave no traces in the workspace. I also can't imagine this happening too often, but still...
Any innocent change to your packages could break stuff.
The obvious danger of monkey-patching what wasn't expected or supposed to be changed. We have specs to alert us of breakage, but there's no telling what would be involved in the repair. We both know this is the wrong approach.
Now, I don't know how the Atom team would feel about adding support for third-party package services. Ideally, this would be addressed on the level of Atom's core icon-API. However, the differences of our needs (as well as the specific use-case of our needs) make me hesitant to propose a change to your existing service, especially because @as-cii has stressed he prefers keeping its functionality simple for the time being. In light of that, it would be more appropriate and ergonomic to support a third-party service in the interim, should a mutually-compatible solution be realised in future.
What this service does
The
file-icons.element-icons
service, when consumed, provides a function to add dynamic icons to DOM elements. The function is to be called by the package on any element that's supposed to represent a filesystem resource (either files, or directories):Calling the function returns a Disposable that clears the icon-node instance from memory, which should be done once the view is destroyed.
Note there's no requirement to specify whether a path is a file or directory. Our heavy-duty filesystem API takes care of the heavy lifting... I've even plans to separate it from File-Icons in the form of a standalone Node module, so other package authors can benefit from my hard work too. :)
Related pull-requests
atom/tree-view#1146
atom/tabs#412
atom/find-and-replace#870
atom/fuzzy-finder#281
atom/archive-view#47