-
-
Notifications
You must be signed in to change notification settings - Fork 284
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
Support multiple webviews on a single WebContext (webkit2gtk) #359
Conversation
I had forgotten that I messed around with more succinct os specific |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just took a look and I think fine to add these if there's no other way to do so.
Maybe we could report to upstream first since it's more like a webkitgtk issue.
I suppose we can remove Windows param in custom protocol first if even tauri doesn't use it.
And the config flags update could also open another PR for a quick merge.
drop(protocols); | ||
|
||
if exists { | ||
Err(Error::DuplicateCustomProtocol(name.to_string())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conflict of duplocate custom protocol only happen if they share same web context.
I think this should let users to decide and we could add some warnings on the behaviour of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, in my item #2 the with_custom_protocol
returns a Result
like some of the other builder items so that the user can choose to ignore it instead of it popping off in the InnerWebView constructor. I think we can support custom protocols on both the WebviewBuilder
and the WebContext
, where using WebviewBuilder
it will just swallow this result inside the webview constructor, and from WebContext
it allows the user to handle it how they want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with register_uri_scheme
and try_register_uri_scheme
. Both will return an Err(DuplicateCustomProtocol)
when a duplicate is passed, but the non-try one will still pass it to the underlying platform (only webkit2gtk in this instance). The code in InnerWebview
has been updated to keep the old behavior. I'll leave this conversation open if you think we should resolve it another way.
I decided to keep it like this because I think there should be another PR after this for adding the register URI functions to the WebContext
itself, which will expose both. The current WebviewBuilder
method if we keep it will continue to use the existing way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to add both methods. But for adding URI method to WebContext
should be exclusive on Linux imho.
Mac and Windows handle them differently (and it's even a hack on Window for now). They probably don't need it.
This should be done if that last conversation resolves. I am going to go ahead and open up another PR from this branch for removing |
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
The PR fulfills these requirements:
fix: #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
This PR uses locks to prevent an unknown concurrency bug with webkit2gtk from happening when using
load_uri
on multipleWebView
s in a sharedWebContext
. The sharedWebContext
is needed for multi-window automation to take place withwebkit2gtk
.Ideally, before release I would also like to see the following improvements:
with_custom_protocol
toWebContext
on all platforms. This involves removing&Window
from the handler._
) out the&Window
and ignore it.Window
that registered the custom protocol is passed instead of theWindow
that it is running on.Result
so thatwry::Error::DuplicateCustomProtocol(String)
can be passed down.The breaking change is that duplicate registering of custom protocols on unix will now fail. Without the improvements listed above, the solution for multi window applications is to add something like