Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
This PR removes CEF and CEFSharp from the libraryViewExtension and replaces it with
Microsoft.Toolkit.Wpf.UI.Controls.WebViewread more here:
https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/wpf-winforms/webview
which renders with edge.
This investigation was started as a way for hosts of Dynamo that have dependencies on other versions of CEF to maintain a functioning and similar user experience.
The available apis are much simpler than CEFSharp - and much more restricted - but after much finagling I think I have almost everything working as before with slower startup time, but faster actual performance during use. The code is simpler, but currently fragile, we can work to improve its robustness over time.
❗️
My intention with this PR is to get feedback and testing - I think to actually deliver this component we should make it a separate extension and test it in other integrations before pulling it into core.
Description of architecture:
This component only really allows interacting between C# and JS in two ways. -
window.external.notify(string) method - which triggers an event on the c# side or -
InvokeScriptAsync(strings)which invokes a method on the js side - only strings can be passed between the contexts.It was not hard to refactor out the events and method calls we were using previously to a single event handler with a dumb format (functionName, params) where params are some json encoded data.
The biggest challenge in this integration is to deal with resource loading - unlike CEFSharp - we cannot intercept requests from the browser context and return data back - we can only serve files from specific folders - I never got this to work, and didnt' really want to serialize data on the fly just to load it back into the webcontext - instead everything(images, fonts svgs etc) is embedded into the json and html that we load or that we serialize and pass to the library functions.
I have refactored the resourceProviders to find the correct resources and convert them to base64 encoded strings which are then used to replace the filePaths which we passed previously. This is likely wasteful and can be optimized if we have repeated icons. We can also likely cache repeated lookups for images we have read from disk previously. None of this is done (except for the default icon because come on 😉 )
interesting facts!
RevitAPI.dll.here is what I have tested:
here is what I know we need to do:
Declarations
Check these if you believe they are true
*.resxfilesReviewers
@QilongTang @reddyashish
FYIs
@Dewb @aparajit-pratap @Amoursol @kronz @angelowang