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

Allow for asynchronous inspector updates #24863

Merged
merged 9 commits into from
Oct 29, 2024

Conversation

bluebear94
Copy link
Contributor

@bluebear94 bluebear94 commented Sep 22, 2024

Resolves: #14383

Previously, updating the inspector model would cause QML components to be created synchronously, causing a delay when selecting certain elements. We set an incubation controller on the QQmlEngine to allow for objects to be created asynchronously when requested. To avoid blocking the main thread when updating the inspector, we also replace the StyledFlickable + Repeater combo with a StyledListView.

Current bugs: the space above the separator lines is missing

  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects, and references the issue it resolves
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable) – N/A

@cbjeukendrup
Copy link
Contributor

This looks good to me now! Are you planning to make further changes in this PR, or is it time to mark it 'ready for review' so that I can approve it?

@bluebear94 bluebear94 marked this pull request as ready for review September 24, 2024 21:23
@bluebear94
Copy link
Contributor Author

I don’t have any further changes planned.

@RomanPudashkin
Copy link
Contributor

@bluebear94 please rebase your PR to fix the red vtests, thanks!

@DmitryArefiev
Copy link
Contributor

DmitryArefiev commented Oct 23, 2024

Tested on Win10, Mac13.6, LinuxUbuntu24.04.1 LTS

@bluebear94 Sorry for delay in testing. I found a regression on Mac with Inspector updating when using select all and switching between panels

  1. Make sure MS opens with Palette panel by default after opening score
  2. Run MS
  3. Open
    inspector .zip (Palettes panel is opened)
  4. Cmd+A (select all)
  5. Switch to Properties panel
  6. Scroll down
  7. Click on empty space in score - Properties panel becomes totally empty
Screen.Recording.2024-10-23.at.16.38.51.2.mp4

@cbjeukendrup
Copy link
Contributor

Perhaps need to call returnToBounds() at some point, maybe onContentHeightChanged.
Or add something like cacheBuffer: 3 * height (see https://doc.qt.io/qt-6/qml-qtquick-listview.html#cacheBuffer-prop).

@bluebear94
Copy link
Contributor Author

@DmitryArefiev I don’t have macOS, so let me know if one of @cbjeukendrup’s suggestions fixes the issue for you.

@DmitryArefiev
Copy link
Contributor

@bluebear94 I'm not a developer (can't change the code on my side).. You can push those suggestions sequentially and I'll check it on macOS

@bluebear94
Copy link
Contributor Author

I’ve pushed the first suggestion; let me know whether it fixes the bug on macOS.

@cbjeukendrup
Copy link
Contributor

@bluebear94 I tried it out and this seems to work for me. However, I noticed some QML warnings, and some more code that turns out to become redundant given your changes, so I created a few commits here: master...cbjeukendrup:MuseScore:properties/optimisations
You could try out that branch, to be sure that it doesn't regress the performance improvements from your changes, and if it's okay, you can cherry-pick those commits to your branch.

Additionally, it would be good to rebase your PR branch: git pull --rebase upstream master && git push -f

This allows object creation to be asynchronous when specified.
We use the controller from the main window.
Replace the StyledFlickable + Repeater with a StyledListView as
suggested by @cbjeukendrup.
@bluebear94
Copy link
Contributor Author

bluebear94 commented Oct 27, 2024

Unfortunately, rebasing onto master seems to have regressed the performance improvements. Okay, I applied the trace-inspector-section-latency patch and it still prints out time values well below 1ms.

Usually, QML ListView will guess the height of the entire list content based on the list items that are currently inside the viewport. In the case of the properties panel, that doesn't work well, because the different sections have very different heights. That can lead to jumping during scrolling. Setting `cacheBuffer` to `contentHeight` prevents this. Note that this is normally completely against the principle of ListView, because it means in practice that all items will always be instantiated instead of only those inside the viewport, but in the case of the properties panel, that's okay, because we're using ListView for its asynchrony, not for its viewport-only efficiency.
@DmitryArefiev
Copy link
Contributor

@bluebear94 @cbjeukendrup Ready for testing?

@bluebear94
Copy link
Contributor Author

Should be.

@DmitryArefiev
Copy link
Contributor

Good.

This issue #24863 (comment) no longer occurs on macOS

Tested on Win10, Mac13.6, LinuxUbuntu24.04.1 LTS - PASS

@RomanPudashkin
Copy link
Contributor

@bluebear94 thank you so much!

@RomanPudashkin RomanPudashkin merged commit 67f35aa into musescore:master Oct 29, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants