stevencohn / OneMore

A OneNote add-in with simple, yet powerful and useful features
Mozilla Public License 2.0
2.56k stars 214 forks source link

Navigator Stutters OneNote interface on pages with a large number of titles #1533

Closed jasonjac2 closed 3 weeks ago

jasonjac2 commented 1 month ago

Problem to Solve

As always, thank you for your work on the add-in.

When Navigator is up and you navigate to a page with a large number of titles, it causes OneNote to stutter (and anecdotally increases OneNote hangs)..

My problem is that my "monthly" pages have a heading for each day, plus 5 sub headings: Must; should; nice; extra; log, so by the end of the month, that is 31*6 headings and 40+ "page downs". Combine this with having about 5+ instances of onenote up and flicking between them rapidly throughout the day, causes OneNote to perpetually be stuttering and so I don't use Navigate as much as I would like to and can't leave it as a "always up" window.

A clear and concise description of what the bug is. It appears that when you goto a page there is a process whereby:

Steps to reproduce the behaviour: I have sent you a video "OneMore Stutter with navigator" (to follow in the next few mins)

Proposed Behavior

I assume that this is not a problem a lot of people are having it and unless there is a very clear optimisation that can occur in the getting; parsing; list generation, then the next best thing is to be able to do one of the following:

Bonus: Allow filtering in the window :-).

stevencohn commented 1 month ago

Note to self: keep everything down to here pre-invoke to stay off the UI thread

@jasonjac2 The navigator is not tied to any OneNote window on purpose. Instead, it polls the Navigator.json file on a regular interval, which can be changed in Settings. It defaults to two seconds and can be set 1..60. The hot path is when it tries to build out the hyperlinks for display; that API back to OneNote is slower than it should be, but that's also internal to OneNote's API. So while I may not be able to increase the speed very much, I should have a couple of alternative that don't lock up the UI thread... Will take a look.

jasonjac2 commented 1 month ago

"The hot path is when it tries to build out the hyperlinks for display; that API back to OneNote is slower than it should be, but that's also internal to OneNote's API." So does this mean that it building the "Headings" for the current page - which is the bit that takes the time (top list) there are n call backs to the ON API (n = number of headings?). Could it delay this until you actually click one of them? I can't work out whether it is the size of the page OR the number of headings - I could test this with a massive page with a few headings vs a small page with loads of headings.

jasonjac2 commented 1 month ago

I assume: await using var one = new OneNote(); var heading = (Models.Heading)label.Tag; await one.NavigateTo(heading.Link); is expensive and is called for a squillion headings that won't get clicked

stevencohn commented 1 month ago

No, that's where navigation happens when you click on a heading to force OneNote to move to that page. That's pretty quick.

Building the hyperlinks starts here where it loads the page and collects the headings. That part is quick.

The slowness is here where gets the hyperlink for each heading. This line is wrapper of the OneNote API but it's that wrapper OneNote API that is slow. Nothing can be done about speeding up the API.

But the current code has that running on the UI thread for OneMore which is likely causing responsiveness issues in OneNote as well. My theory is that I can keep this in a background thread until all hyperlinks are discovered and the switch over to the UI thread to update the Navigator display. Worth a shot anyway.

jasonjac2 commented 1 month ago

"hyperlinks are discovered and" Ignore me if you're busy, but just trying to get it into my head: For each heading...... there is a callback into ON and those are expensive? If so, can't you defer those until one is actually clicked?

jasonjac2 commented 1 month ago

I should really compile the blinking code and learn rather than just ask away!

stevencohn commented 1 month ago

can't you defer those until one is actually clicked?

Um, er, well, that would be smart, wouldn't it?

jasonjac2 commented 1 month ago

I can't tell if you are mocking me :-).

stevencohn commented 1 month ago

Mocking myself!

stevencohn commented 1 month ago

Result

jasonjac2 commented 1 month ago

Wow, so thorough. Thank you for that.

jasonjac2 commented 1 month ago

What are you hoping to cram in before the next release and any idea of when? Have you thought about doing a RC and getting help with the docs?

stevencohn commented 1 month ago

I generally keep an eye on these three filters day-to-day

I try to keep the docs up to date with every ticket. Remember, it's a local notebook that I only publish to the Wiki with each release, so there's a lot of work happening in the background.

There is more work to complete in #1335, which admittedly is quite large since I've used it to finally address some long-awaited refactoring; that, in turn, uncovered some other hidden problems that need solving before a release.

So, next couple of weeks or sooner if I can?!

Finally, the following info section will be published as part of the vNext release notes. These are ideas/thoughts/known issues that haven't become tickets yet. Here's a preview:

Known Issues and Proposed Updates

🐜Reduced an issue where Command/Quick Palette dialogs would cause the OneNote window to flicker; this changes the opening behavior of the Palette dialogs, hiding the command list until you start typing, #1422. However, the flicker still randomly occurs. 🐜 SearchAndReplace doesn't replace the currently highlighted or selected word/phrase; sometimes it doesn't replace other candidates either 🐜Replaying a command using Ctrl+Shift+R is done in a single thread, breaking progress.RunModeless; see CreatePagesCommand 🐜Select Similar Styles will find differences in colors Auto vs #000000 - make it more fuzzy? 🐜PasteText should convert CRLF to hard-breaks, currently creates soft-breaks 💡Command to convert friendly URLs to raw URLs; References menu 💡Paginate Hashtag search results 💡Move Navigator to DB, paginate history panel, provide import/export 💡Move Reminders to DB, option in dialog and on-page link to delete completed reminders 💡Github PR action to pull ticket# prefix from branch name, e.g. 1234-do-something-cool

jasonjac2 commented 1 month ago

Excellent, thanks for the information.
"So, next couple of weeks or sooner if I can?!" amazing. On the "move to DB..." items, if you do that, will filter be easier to implement later? If you have a workaround for #1523 that would be great (rather than just delete them all and start again).

stevencohn commented 1 month ago

DB - yes, filtering, pagination, and helps cross-machine mapping to pages where we know there is problem in that OneNote is free to assign different IDs to things which breaks, well, everything!

Moving Favorites there will have the same benefit.