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

introduce node count threshold for opacity animations on zoom #15764

Merged

Conversation

mjkkirschner
Copy link
Member

@mjkkirschner mjkkirschner commented Jan 17, 2025

Purpose

extracts some changes from:
#15749 by @dimven

For a sense of what theses do in terms of interaction performance / UI feel please see the original PR description for gifs.

Essentially we do not animate opacity changes when zooming as this has very poor performance that we cannot control.
Instead, only trigger these animations if the total number of nodes in the graph is under some threshold.

TODO:

  • create feature flag
  • use feature flag for the threshold
  • - adding some logging to WPF it looks like these find ancestor calls take about 400 microseconds per node, thats about 2500 nodes in a second, and that cost should only be paid once (when the binding is first attached), even though the StopAnimations property feels kind of static to me anyway... I just don't think it's worth messing with it at the current time.
  • consider tests for checking threshold

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB

Release Notes

improve zoom performance by only animating opacity changes if there are few nodes in the graph.

@dimven-adsk
Copy link
Contributor

Something else that came to mind was setting the visibility property instead of the opacity for the basic styles. Tho I'm not sure if the benefit is worth the extra complexity. Since we're switching between two styles, we would have to add the visibility property to both styles.

@mjkkirschner
Copy link
Member Author

Something else that came to mind was setting the visibility property instead of the opacity for the basic styles. Tho I'm not sure if the benefit is worth the extra complexity. Since we're switching between two styles, we would have to add the visibility property to both styles.

thanks @dimven-adsk that makes sense, I may leave that as a TODO and file a follow-up optimization so these PRS don't drag on forever though.

@mjkkirschner mjkkirschner changed the title WIP - introduce node count threshold for opacity animations on zoom introduce node count threshold for opacity animations on zoom Jan 27, 2025
@pinzart90
Copy link
Contributor

I will leave this here for posterity:

Animating the [Opacity](https://learn.microsoft.com/en-us/dotnet/api/system.windows.media.brush.opacity) of a [Brush](https://learn.microsoft.com/en-us/dotnet/api/system.windows.media.brush) provides performance benefits over animating the [Opacity](https://learn.microsoft.com/en-us/dotnet/api/system.windows.uielement.opacity) property of an element.

https://learn.microsoft.com/en-us/dotnet/desktop/wpf/graphics-multimedia/how-to-animate-the-opacity-of-an-element-or-brush?view=netframeworkdesktop-4.8
I tried to switch from element to brush, but it is not as straight forward as I though. It could be done on top of this PR (for bellow the threshold)

@Jingyi-Wen
Copy link

The animation looks good to me

@pinzart90
Copy link
Contributor

The animation looks good to me

What about the lack of animation in big graphs ?

@mjkkirschner
Copy link
Member Author

The animation looks good to me

What about the lack of animation in big graphs ?

discussed over chat with @Jingyi-Wen - @pinzart90 I think we are good to proceed with this if you approve. We can tune the feature flag later, for now I will set it to 150.

@@ -76,7 +76,7 @@ public void FeatureFlagsShouldMessageLoggedShouldContainAllLogs()
StringAssert.Contains("\"TestFlag1\":true", log);
StringAssert.Contains("\"TestFlag2\":\"I am a string\"", log);
StringAssert.Contains("\"graphics-primitive-instancing\":true", log);
StringAssert.EndsWith("<<<<<Eod>>>>>", log);
StringAssert.Contains("<<<<<Eod>>>>>", log);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this about ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pinzart90 due to the changes you call out below.

@@ -75,6 +75,8 @@ internal void CacheAllFlags()
FlagsRetrieved?.Invoke();

}, null);
var formattedFlags = JsonConvert.SerializeObject(AllFlagsCache, Formatting.Indented);
OnLogMessage($"retrieved feature flags with value: {formattedFlags}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this just a debugging thing ? or it makes sense for users too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging from ff had performance issues in the past. Might OnLogMessage trigger Wpf updates ?

Copy link
Member Author

@mjkkirschner mjkkirschner Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely has WPF updates as it triggers the log text binding to update, but this is a single log, and as we get more and more flags, the other log that we have that spits out the std.out is not readable. This makes it much easier IMO for devs to see what flags are enabled when a user gives us their log.

Copy link
Contributor

@pinzart90 pinzart90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of questions. LGTM

@mjkkirschner mjkkirschner merged commit 20d268a into DynamoDS:master Feb 5, 2025
22 of 24 checks passed
@mjkkirschner mjkkirschner deleted the reope/opacityanimationchanges branch February 5, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants