Slow UI performance after migrating from 4.8 to .net 8

Slow UI performance after migrating from 4.8 to .net 8

ngirgis46ZBV
Observer Observer
396 Views
1 Reply
Message 1 of 2

Slow UI performance after migrating from 4.8 to .net 8

ngirgis46ZBV
Observer
Observer

Hi everyone,

 

So I have a Revit plugin with WPF UI that was working perfectly in 4.8 framework, very quick connection to backend api and very responsive UI. when we migrated to .net 8, the plugin is working but the UI is very slow initially, every first click of a UI element feels like this UI element is being loaded. After the first click, clicking on the UI element is smooth as expected and as it was in 4.8 framework.
We have spent 3 days troubleshooting this issue and we couldn't find a solution or the root cause. Did anyone face same issue before?

 

Cheers
Nayer

0 Likes
397 Views
1 Reply
Reply (1)
Message 2 of 2

kaiZQHQ4
Contributor
Contributor

It'd be helpful to know your stack, but i have encountered lots of wpf-related and json-related package resolution issues with the same packages in net48 and net8. Sometimes the resolution takes an absurd amount of time, not sure why. I'd recommend adding this to your IExternalApplication:

internal class App : IExternalApplication {
    public Result OnStartup(UIControlledApplication app) {
        // Set up assembly resolver for Wpf.Ui and other dependencies
        AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
        // ...
    }


    private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) {
        Debug.WriteLine($"Assembly Resolution Requested: {args.Name}");

        // Get the assembly name being requested
        var assemblyName = new AssemblyName(args.Name);

        // Get the directory where this add-in's DLL is located
        var addinPath = typeof(App).Assembly.Location;
        var addinDirectory = Path.GetDirectoryName(addinPath);
        if (addinDirectory is null) return null;

        // Construct the path to the requested assembly
        var assemblyPath = Path.Combine(addinDirectory, $"{assemblyName.Name}.dll");

        // Load and return the assembly if it exists in our add-in directory
        if (File.Exists(assemblyPath)) {
            Debug.WriteLine($"Loading assembly from: {assemblyPath}");
            return Assembly.LoadFrom(assemblyPath);
        }

        Debug.WriteLine($"Assembly not found in add-in directory: {assemblyPath}");
        return null;
    }


Take this with a grain of salt, but it seems to me that if a package is failing to resolve, then revit performs its own internal resolution process everytime the package is needed, which causes some major overhead. In my env, it also seems like wpf-ui never resolves on its own, thus why i had to add this OnAssemblyResolve in the first place

0 Likes