In the FXM version, when using an independent cache, the page content loads extremely slowly. This has been tested multiple times
chenzhifeng0025 opened this issue · 1 comments
In the FMX version, when using an independent cache, the page content loads extremely slowly. This has been tested multiple times
I used the FMXTabbedBrowser demo project and modified the code in the procedure TBrowserFrame.CreateBrowser to give each page an independent cache directory. The code is as follows:
procedure TBrowserFrame.CreateBrowser;
var
RequestContext: ICefRequestContext;
{$IFDEF MSWINDOWS}
TempHandle: HWND;
TempRect: System.Types.TRect;
TempClientRect: TRectF;
{$ENDIF}
begin
CreateFMXWindowParent;
if not (FMXChromium1.Initialized) then
begin
TempHandle := FmxHandleToHWND(FMXWindowParent.Handle);
TempClientRect := FMXWindowParent.ClientRect;
TempRect.Left := round(TempClientRect.Left);
TempRect.Top := round(TempClientRect.Top);
TempRect.Right := round(TempClientRect.Right);
TempRect.Bottom := round(TempClientRect.Bottom);
FMXChromium1.DefaultUrl := FHomepage;
//These few lines are the modified code.
var TempCache := 'D:\cache2';
var TempContext := TCefRequestContextRef.New(TempCache, '', '', False, False, False, FMXChromium1.ReqContextHandler);
FMXChromium1.CreateBrowser(TempHandle, TempRect, '', TempContext);
end;
end;With this code, opening a page makes the web page almost unusable, as it becomes extremely laggy. I've tested it multiple times, and the results are always the same. However, if I set var TempCache := '';, it works normally. This issue doesn't occur in the VCL version.
I just uploaded a new version of the FMXTabbedBrowser demo with an option to create independent browsers.
Notice that GlobalCEFApp.RootCache is a parent directory of all the cache directories.
The Windows user running the application requires write privileges in GlobalCEFApp.RootCache.
The browser has to download all the page contents whenever a new independent browser is created because the cache is empty.
If you want to create several browsers sharing the same private cache directory then you must use TChromiumCore.ShareRequestContext to get a new ICefRequestContext and pass NewWebBrowser.ReqContextHandler as the second parameter.
There are several factors that affect the browser speed like an empty cache, proxy servers, firewalls, antivirus software, etc.
FMXTabbedBrowser uses a browser in "windowed mode" and it should work as fast as TabbedBrowser2 in VCL.