To off screen or not to off screen #4865
Replies: 2 comments 2 replies
-
I am trying to arrange a browser control element as a tab item in a tab control. However, when I run a check whether I could sign in, it is hanging on the first control selector Below, blurred for privacy, tab control and browser on the right, sign in controls on the left, obviously. await using var context = await browser.CreateDevToolsContextAsync();
var opts = DevToolsWaitForSelectorOptions;
// Hanging up here:
var a = await context.WaitForSelectorAsync(S.Password, opts);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
var b = await context.WaitForSelectorAsync(S.Username, opts);
var c = await context.WaitForSelectorAsync(S.RememberMe, opts);
var d = await context.WaitForSelectorAsync(S.Submit, opts);
return !(a is null || b is null || c is null || d is null); Options are nominal as far as I know: private static WaitForSelectorOptions DevToolsWaitForSelectorOptions => new() { Timeout = 1000, Visible = true }; I have validated the approach is more or less sound; but I wonder if I am encountering some off screen aspects. Rather how to persuade the await when the browser is another control in the same window. |
Beta Was this translation helpful? Give feedback.
-
The You can create the See https://github.com/cefsharp/CefSharp/blob/cefsharp/126/CefSharp.Wpf/ChromiumWebBrowser.cs#L529 The example demos adding the browser when it's been created, you can just defer this until your ready to show it to the user. You may also wish to change the framerate when the browser is not visible to reduce resource load. |
Beta Was this translation helpful? Give feedback.
-
That is the question.
I have a case where, it might be helpful to sometimes show the WPF browser
Window
, but most of the time, I think we will be content to maintain a browser presence off screen as it were.The challenge I am faced with, however, maybe why there is a separate off screen package (?), is that I might like to support more of a hybrid approach. The window should be able to be made visible when necessary; but should still operate seamlessly off screen.
The inner workings, as far as I am aware, is that the browser is not rendering, and/or has not rendered, when the window is hidden. And more inward than that, the
BrowserCore
instance has not been initialized until that point. And which allows for things like context to be arranged and so forth.So, the question for me is, is there a recommendation for this sort of hybrid approach?
Beta Was this translation helpful? Give feedback.
All reactions