Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

How to suspend several TChromium browsers without closing?

Post Reply
Svt
Posts: 1
Joined: Thu Jan 04, 2024 12:34 am

How to suspend several TChromium browsers without closing?

Post by Svt »

Hello! Happy New Year!

I have a problem:

I have a project based on the Tabbedbrowser sample.
I need to open a lot of pages.
But when 20-30 pages opened, they are slowing down if I trying to work with one of them, all operations processing very slow.
How can I to suspend all other pages when I want to interact with one page?
My idea is:
1. I have 20 pages opened.
2. I need to enter page 7 and work with it
3. I suspend pages 1-6 and 8-20 so they are not refreshing, scripts not working, etc.
4. I do something with page 7 and end my task
5. I resume pages 1-6 and 8-20, and all pages continue working normally.

How can I do this?
Please help if you can.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to suspend several TChromium browsers without closing?

Post by salvadordf »

Hi,

Try setting the TCEFWindowParent.Visible property of each hidden page to False. Also try pausing videos in hidden tabs.
Svt
Posts: 1
Joined: Thu Jan 04, 2024 12:34 am

Re: How to suspend several TChromium browsers without closing?

Post by Svt »

No, it does nothing.
I need to disable scripts on the page.
Try to open page: https://www.mexc.com/exchange/BTC_USDT
You will see MEXC cryptoexchange with a lot of data on the page
This page always send requests to the server to autoupdate data

--------------------------------------------------------------------
I wrote OnBeforeLoadResource handler: (write page requests to SL (TStringList))

procedure TF_Main.Chromium_OnBeforeResourceLoad(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const callback: ICefRequestCallback;
out Result: TCefReturnValue);
var
s,ref: string;
begin
s:= request.Url;
ref:= request.ReferrerUrl;
if fLogWrite then
SL_Log.Add(TimeToStr(Now)+': '+s+' / ’+ref);
end;

-------------------------------------------------------------
This is the part of a log generated by this handler:

8:07:20: https://www.mexc.com/api/common/config/sites / https://www.mexc.com/exchange/BTC_USDT
8:07:21: https://trochi.gotoda.co/api /
8:07:21: https://trochi.gotoda.co/api /
8:07:24: https://www.mexc.com/api/common/ping / https://www.mexc.com/exchange/BTC_USDT
8:07:25: https://www.mexc.com/exploration/explorationNoCache.json / https://www.mexc.com/exchange/BTC_USDT
8:07:25: https://www.mexc.com/exploration/exploration.json / https://www.mexc.com/exchange/BTC_USDT
8:07:26: https://trochi.gotoda.co/api /
8:07:30: https://opt.mocortech.com/maintenance/events.json / https://www.mexc.com/exchange/BTC_USDT
8:07:33: https://www.mexc.com/api/common/ping / https://www.mexc.com/exchange/BTC_USDT
8:07:34: https://trochi.gotoda.co/api /
8:07:34: https://trochi.gotoda.co/api /
8:07:35: https://www.mexc.com/api/common/ping / https://www.mexc.com/exchange/BTC_USDT
8:07:35: https://www.mexc.com/exploration/explorationNoCache.json / https://www.mexc.com/exchange/BTC_USDT
8:07:36: https://trochi.gotoda.co/api /
8:07:36: https://www.mexc.com/exploration/exploration.json / https://www.mexc.com/exchange/BTC_USDT
8:07:37: https://trochi.gotoda.co/api /
-----------------------------------------------------------

How to disable these requests to prevent page data autoupdate?
Not to set RV_Cancel in this handler for these requests, but how to make to page would send no requests?
And how to enable sending these requests later to enable data autoupdate again?
Last edited by Svt on Sun Jan 14, 2024 5:32 am, edited 2 times in total.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to suspend several TChromium browsers without closing?

Post by salvadordf »

CEF doesn't have TrySuspend/Resume like WebView2 but the CEF project maintainer also recommends using the off-screen rendering mode and calling WasHidden(true).
https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=17737

You can try this with the TabbedOSRBrowser demo.
Post Reply