need help winform RequestContext/share render process

Having problems with building or using the CefSharp .NET binding? Ask your CEF-related questions here. Please ask general usage questions on StackOverflow.

Moderator: amaitland

Re: need help winform RequestContext/share render process

Postby nhatnm » Fri Jun 04, 2021 7:38 pm

amaitland wrote:Does SharpBrowser use a RequestContext to isolate it's ChromiumWebBrowser instances?
I've you tried removing all the command line args/settings except CachePath?

Try FindAll, I didn't see any RequestContext and CefCommandLineArgs in . I'm silly, didn't think must find this before ask. So, what magic it used?
About your link, I have read and pratice many times. With my understand, it'll help me clear the browser after used RequestContext, then can reload BrowserSettings and CefSettings but not CefCommandLineArgs. I think it's good for use multi-profiles for multi-tabs, right? And does it prossible re-link to other render process?
And I'm also read this your post , I don't know javascript it's hard for me understand. But does it useful for this?
nhatnm
Newbie
 
Posts: 9
Joined: Fri Jun 04, 2021 8:28 am

Re: need help winform RequestContext/share render process

Postby amaitland » Fri Jun 04, 2021 7:48 pm

amaitland wrote:If you have two tabs with one tab active then potentially what you are seeing is Potentially what you are seeing is https://github.com/cefsharp/CefSharp/issues/2922

It's possible the difference between your application and SharpBrowser is how the tabs behave, they appear to be using some form of custom BrowserTabStrip


This is my best guess as to what's going on. Your inactive tab is still running in the background. Manually call Hide()/Show() when the tab changes to ensure the background ChromiumWebBrowser controls are hidden.
Maintainer of the CefSharp project.
amaitland
Master
 
Posts: 965
Joined: Wed Jan 14, 2015 2:35 am

Re: need help winform RequestContext/share render process

Postby nhatnm » Fri Jun 04, 2021 7:49 pm

Yes, thanks your idea, I'll try Control.VisibleChanged
nhatnm
Newbie
 
Posts: 9
Joined: Fri Jun 04, 2021 8:28 am

Re: need help winform RequestContext/share render process

Postby amaitland » Fri Jun 04, 2021 8:13 pm

That's unlikely to work, it's not called when a Control within a TabControl becomes hidden (Visible = false).
Maintainer of the CefSharp project.
amaitland
Master
 
Posts: 965
Joined: Wed Jan 14, 2015 2:35 am

Re: need help winform RequestContext/share render process

Postby amaitland » Fri Jun 04, 2021 8:34 pm

You may need to use a custom implementation like ChromiumWebBrowser like the following to ensure the underlying CefBrowser size is set to 0,0 when hidden to ensure the resource usage is decreased.

Code: Select all
public class ChromiumWebBrowserEx : ChromiumWebBrowser
{
   public ChromiumWebBrowserEx(string address) : base(address)
   {

   }

   protected override void OnVisibleChanged(EventArgs e)
   {
      if(Visible)
      {
         ResizeBrowser(Width, Height);
      }
      else
      {
         ResizeBrowser(0, 0);
      }

      base.OnVisibleChanged(e);
   }
}
Maintainer of the CefSharp project.
amaitland
Master
 
Posts: 965
Joined: Wed Jan 14, 2015 2:35 am

Re: need help winform RequestContext/share render process

Postby nhatnm » Fri Jun 04, 2021 8:43 pm

here's my result: yahoo, it' worked
3.png
3.png (283.78 KiB) Viewed 222 times


my code:
Code: Select all
tab.VisibleChanged += new EventHandler(this.TabVisibleChanged);
private void TabVisibleChanged(object sender, EventArgs e)
        {
            if (Visible)
            {
                //MessageBox.Show("raised");
                tabControl.SelectedTab.Show();
            }
            else tabControl.SelectedTab.Hide();
        }

But I have little question.
- With MessageBox.Show for test, I see it showed 2 times, mean all tab will fire 2 times for every my touch to them. Something incorrect in my do?
- Why this this can make share render process, I can't understand
nhatnm
Newbie
 
Posts: 9
Joined: Fri Jun 04, 2021 8:28 am

Re: need help winform RequestContext/share render process

Postby nhatnm » Fri Jun 04, 2021 8:44 pm

amaitland wrote:You may need to use a custom implementation like ChromiumWebBrowser like the following to ensure the underlying CefBrowser size is set to 0,0 when hidden to ensure the resource usage is decreased.

Code: Select all
public class ChromiumWebBrowserEx : ChromiumWebBrowser
{
   public ChromiumWebBrowserEx(string address) : base(address)
   {

   }

   protected override void OnVisibleChanged(EventArgs e)
   {
      if(Visible)
      {
         ResizeBrowser(Width, Height);
      }
      else
      {
         ResizeBrowser(0, 0);
      }

      base.OnVisibleChanged(e);
   }
}

oops, I'll try your code
nhatnm
Newbie
 
Posts: 9
Joined: Fri Jun 04, 2021 8:28 am

Re: need help winform RequestContext/share render process

Postby amaitland » Fri Jun 04, 2021 8:52 pm

If your resource usage decreased then you likely don't need the code I provided.

Code: Select all
With MessageBox.Show for test, I see it showed 2 times, mean all tab will fire 2 times for every my touch to them. Something incorrect in my do?


You are checking the Visible property for the class you are in, not a specific Tab instance. Your code is likely incorrect.
Maintainer of the CefSharp project.
amaitland
Master
 
Posts: 965
Joined: Wed Jan 14, 2015 2:35 am

Re: need help winform RequestContext/share render process

Postby nhatnm » Fri Jun 04, 2021 9:47 pm

Sorry for my silly question. Could you guide me how to use "ResizeBrowser" in your way?
nhatnm
Newbie
 
Posts: 9
Joined: Fri Jun 04, 2021 8:28 am

Re: need help winform RequestContext/share render process

Postby amaitland » Sat Jun 05, 2021 2:27 am

ResizeBrowser is a protected method and cannot be called directly.
Maintainer of the CefSharp project.
amaitland
Master
 
Posts: 965
Joined: Wed Jan 14, 2015 2:35 am

PreviousNext

Return to CefSharp Forum

Who is online

Users browsing this forum: No registered users and 3 guests