Skip to content
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

Obsidian 1.7.2 - automatic sorting fails when launching Obsidian #163

Closed
bray opened this issue Sep 23, 2024 · 9 comments
Closed

Obsidian 1.7.2 - automatic sorting fails when launching Obsidian #163

bray opened this issue Sep 23, 2024 · 9 comments
Assignees

Comments

@bray
Copy link

bray commented Sep 23, 2024

When launching Obsidian, it no longer automatically sorts when I launch Obsidian. It works when manually sorting via the toggling command.

I was able to get it working on desktop (Mac): I'm using Lazy Plugin Loader, and changing this plugin to load instantly fixes it. That makes it one of the first plugins loaded.

Alternatively, if I disable Lazy Plugin Loader and all plugins except this one, it works on desktop. So, maybe this is related to load order or some other conflict with other plugins?

But neither of those solutions fixes it on Android.

What's interesting to note is in both cases, if I enable notifications, when I launch Obsidian, it shows both "Custom sorting ON" and "Parsing custom sorting specification SUCCEEDED!", but doesn't actually do the sorting.

Not sure if the same or related to #162.

@SebastianMC
Copy link
Owner

Thanks @bray for reporting this with a series of insightful details!

@Azmoinal
Copy link

I don't know if it helps but automatic sorting works for me on desktop if File Explorer is visible at Obsidian startup, if another view was open in right sidebar at startup the automatic sorting fails.

On the other side, on iOS even if File explorer is the view in the right sidebar at startup, custom sorting fails to apply automatically.

@SebastianMC
Copy link
Owner

Hi @Azmoinal

to better understand what happens under Obsidian 1.7.2 I've done a series of tracked executions of various start up sequences of the plugin. Including the Lazy Plugin Loader mentioned by @bray.

BTW the Lazy Plugin Loader plays unfair with delayed plugins and hurts them. It literally removes the delayed plugins from Obsidian's hands and starts these plugins by itself, by disabling and enabling them. This can interfere with internal logic of plugins because the internal handling of 'plugin was enabled' and 'plugin was disabled' are normally edge cases and can involve heavy initialisation or cleanup of internal databases, statuses, data files, etc. Also normally plugins receive some events from Obsidian on start up, which are not delivered when the Lazy Plugin Loaded uses the 'enable plugin' way to start a plugin.

Knowing the above it turns out that handling of the plugin startup sequence under 1.7.2 is a whole different world than when the custom-sort plugin was originally created. A rethinking and rework of the internal start up logic is required to handle as much of the scenarios as possible, including Lazy Plugin Loader.

Yesterday I've created a new branch dedicated for the experiments around correct handling of various start up sequences.

@bray
Copy link
Author

bray commented Sep 25, 2024

That must be frustrating. Unfortunately, a lot of people are turning to the Lazy Loader because of slow startup times for their plugins. It is a nice option if you use a lot of plugins, but I can see how it's more to handle as plugin developers.

But thanks for your work on getting all this sorted!

@GrayStrider
Copy link

I was trying to edit my sorting order today (bookmark drag and drop appears to be bugged in the latest Android version, so I had to resort to JSON editing), and after I have noticed that custom sorting did not apply automatically on startup anymore, which I'm pretty sure wasn't the case just a few hours ago (I would have noticed the orange icon). It would appear that some changes in the configuration enabled the behavior described by OP. My plugins were updated yesterday, as well as application itself.
Not terribly helpful, I imagine, still, best of luck in figuring out the solution.

@tdtrumble
Copy link

Just adding in my experience in case it shed light on anything. I don't use lazy plugin loader, but do use a decent number of core and community plugins. I use the sortspec file approach.

In iOS it never sorts at startup despite saying custom sort is on. Toggling it off and back on works to apply the sort.

On desktop (windows 11) it's not consistent, sometimes it applies and sometimes it doesn't, but toggling off and on fixes it.

If I'm feeling adventurous I might try utilizing some different methods like bookmarking and index files to see if I can find a method that works. If anyone else has found one, please post 🙏

@tomoayan
Copy link

tomoayan commented Nov 5, 2024

Temporary fix for auto sorting

Install Commander and make a new macro.

  • Add the name of macro
  • Add 2-3 seconds of delay
  • Add the sort on command
  • Check the option of "Auto-Run on Startup"
  • Make sure to save it!

Macro Settings

How it works?

On Obsidian startup commander runs the macro and waits for 2-3s and then it runs the next sort command. This delay ensures that custom-sort plugin is loaded before the next command gets executed.

@SebastianMC
Copy link
Owner

Hi @tomoayan,

thanks for posting the instructions on temporary fix using delayed Commander action!

It is equivalent of manual triggering of the custom sort and it will help in the scenarios needing that, for example with Lazy Plugin Loader.

At the same time, let's keep in mind that there are (at least) two major problematic scenarios which require a different treatment:

  • prevalent on mobile, when Obsidian needs much time (tens of seconds) to parse all notes in the vault upon app/vault load. This is done by Obsidian in the background and until Obsidian parses the entire vault, there could be problems with custom sorting. The toolbar icon can indicate success, at the same time no sorting applied. From technical perspective the source of problem here is that reading of the sorting specs, being part of notes metadata, depend on this background Obsidian task. As for now I don't see any reliable solution to that scenario.
  • when the File Explorer view is not displayed on app/vault load (the Deferred Views optimisation of Obsidian 1.7.2). The dependency here is simple - no File Explorer view, hence no place to sort items. The moment to apply custom sort automatically in this scenario is when the File Explorer is displayed later on. Unfortunately Obsidian doesn't expose a notification mechanism (I didn't encounter such mechanism at least) so that the plugin could react.

@SebastianMC
Copy link
Owner

Plugin release 3.1.0 addresses the issues by introducing delayed auto-application of custom sort. The delay is configurable, by default 1 second.
If FIle Explorer remains invisible and deferred, an explicit notification is shown. Manual re-applying the custom sort (command sort-on, ribbon button click) works then normally when File Explorer is displayed.

If the issue still persists, please reopen this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants