Page 1 of 2

Over 900 =) MDIBrowser

Posted: Fri Jul 22, 2022 5:49 pm
by dilfich
Hi, the example is certainly rude, but I think the question will be clear. What is the limitation of copies under one OS? How to run 100-200 independent OSR instances? If a lot of them constantly fly out. In the "Media browser" and 100 do not work, heavily load the CPU. For a long time, <<80 version did not seem to have such problems, I ran under 200 osr in one application. :?

Why in earlier versions there were no problems with this, not to say that the load was small, but now it is unbearable. Perhaps something needs to be configured, or it is now the specifics of all new versions.

incognito mode

Code: Select all

[b]TMainForm[/b]

procedure TMainForm.Timer1Timer(Sender: TObject);  // Interval 1000
begin
 Inc(FBCount);
 MainForm.NewBtn.OnClick(MainForm); Button1.Caption:= IntToStr(FBCount);
 if (FBCount >= 100) then begin
  Timer1.Enabled:= False;
  Timer2.Enabled:= True;
 end;
end;

procedure TMainForm.Timer2Timer(Sender: TObject);   // Interval 3 or 5 000
var
  i : integer;
begin
  i := pred(MDIChildCount);
  while (i >= 0) do
    begin
      if not(TChildForm(MDIChildren[i]).Closing) then
        PostMessage(MDIChildren[i].Handle, CEFBROWSER_OPEN_URL, 0, 0);
      dec(i);
    end;
end;

procedure TMainForm.Button1Click(Sender: TObject);
begin
 Button1.Enabled:= False;
 Timer1.Enabled:= True;
end;


[b]TChildForm[/b]

procedure TChildForm.OpenUrl(var aMessage : TMessage);
begin
 Chromium1.ClearCache;
 Chromium1.LoadURL(Edit1.Text);
end;

Re: Over 900 =) MDIBrowser

Posted: Fri Jul 22, 2022 6:23 pm
by salvadordf
That depends on the Chromium version, computer performance, hardware features, operating system load, etc.

https://support.google.com/chrome/thread/27502734/how-many-new-tabs-can-i-open-in-a-single-chrome-web-app?hl=en

Re: Over 900 =) MDIBrowser

Posted: Sun Sep 24, 2023 4:16 am
by tad.chen
Although we can run independent OSR instances as many as possible, the computer resource such as memory and CPU are limited, especially memory.

If the OSR instance becomes not visible, we can hide it. This will release CPU usage of that OSR instance, but memory used by it will not be released! So the number of OSR instances are limited because of limited memory.

Can we save data in the memory used by the OSR instance to disk when it's hidden? And load data in memory from disk when it's actived. If it's possible, we can fix the problem.

Re: Over 900 =) MDIBrowser

Posted: Sun Sep 24, 2023 2:45 pm
by salvadordf
Hi,

The easiest solution would be to use the same buffer panel for all the TChromium components.

Call TChromiumCore.WasHidden(True); when that browser is not visible and TChromiumCore.WasHidden(False); when it's visible.
Call TChromiumCore.Invalidate(PET_VIEW); to force a full repaint when necessary.

TChromiumCore.WasHidden stops the OnPaint event for that browser while it's not visible.

If this solution can't be implemented easily in your application then you can also use a custom buffer panel with a new procedure that calls FreeAndNil(FBuffer). In this case you will have to call TBufferPanel.UpdateBufferDimensions when a buffer panel is visible in order to create FBuffer again.

Re: Over 900 =) MDIBrowser

Posted: Mon Sep 25, 2023 8:28 am
by tad.chen
Thank you for your advice.

But this can only save display memory used by the OSR instance. How to save other part of memory used by the OSR instance? I think the OSR instance will use memory to save information of all DOM nodes, data for web context and so on. Is it possible to save these memory?

Re: Over 900 =) MDIBrowser

Posted: Mon Sep 25, 2023 8:59 am
by salvadordf
That's handled internally by Chromium.

You can try setting TChromium.HighEfficiencyModeState to TCefHighEfficiencyModeState.kEnabled but I'm not sure CEF is compatible with that setting. Consider it experimental.

Instead of hiding the browser you can also try destroying it completely and rely on the browser cache to load that web page quickly the next time.

Re: Over 900 =) MDIBrowser

Posted: Mon Sep 25, 2023 10:37 am
by dilfich
Frequent creation and destruction seems to lead to a Windows glitch. 1000++ times

I solved the problem by working with tabs.
In place of 100 instances, I create 10 with 10 tabs and everything seems to be not bad.

And to reduce the load noticeably helps only - GlobalCEFApp.DisableSiteIsolationTrials:= True; (Somewhere +30% of memory if not disabled)

For example (10 days without a break of work) , when the browser is not used 11 tabs - RAM: 1,527
And when they are already used - RAM: 2,236
This is all about of course and depends on the tasks.
This is not so much if you count the tab as a separate browser.

Re: Over 900 =) MDIBrowser

Posted: Tue Sep 26, 2023 1:47 am
by tad.chen
Hi,
dilfich wrote: Mon Sep 25, 2023 10:37 am I solved the problem by working with tabs.
In place of 100 instances, I create 10 with 10 tabs and everything seems to be not bad.
Thank you for your information.

But I don't understand your method. You create 10 tabs and run 10 instances in each tab?

Re: Over 900 =) MDIBrowser

Posted: Wed Sep 27, 2023 4:50 pm
by dilfich
demo - MDIBrowser: This is exactly what we are talking about, there you just need to split

Code: Select all

TempContext: array [0..MaxARR] of ICefRequestContext;
The path for the cache and all that can also be specified when creating.

Code: Select all

TempContext[0]:= TCefRequestContextRef.New('', '', '', True, True, True, ChromOSR[0].Chromium.ReqContextHandler);
All these tabs will be essentially a separate browser "TempContext[0]",and is also possible to specify a cache separately.
Settings for each instance\tabs can be made separately

Code: Select all

TCefRequestContextRef.New(", ", ", True, True, True,....

Correct me if I'm wrong, but everything seems to work according to this scheme. :|

Re: Over 900 =) MDIBrowser

Posted: Wed Sep 27, 2023 5:07 pm
by dilfich
And there is a nuance) I run the browser by a separate process via "ShellExecute" and communication as a client\server. This makes it possible to restart both independently or in case of any failure.
In one application it not real as it seems to me.

that is, two applications, one manages, the other with browser capabilities.
Difficult, but more reliable. And in general I think the idea is clear.