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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

form closes automatically

Post Reply
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

form closes automatically

Post by Kazann117 »

good day!!!
TempContext := TCefRequestContextRef.New('Date\TG\Date\Accaunt\Accaunt0','Date\TG\Date\Accaunt\Accaunt0',False, False, False, False);
Chromium1.CreateBrowser(CEFWindowParent1,'Date\TG\Date\Accaunt\Accaunt0', TempContext);



the browser starts to close at 70% of the load, what could be the problem
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: form closes automatically

Post by Kazann117 »

It seems to me that it’s not even a matter of code, the folder with cookies is created, and then when you go to any site, the form with the browser just closes and that’s all, even though the folder with cookies changes.
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: form closes automatically

Post by salvadordf »

Hi,

The second parameter for TCefRequestContextRef.New is "aAcceptLanguageList". These are the code comments for that parameter :

Code: Select all

  ///
  // Comma delimited ordered list of language codes without any whitespace that
  // will be used in the "Accept-Language" HTTP header. Can be set globally
  // using the CefSettings.accept_language_list value or overridden on a per-
  // browser basis using the CefBrowserSettings.accept_language_list value. If
  // all values are empty then "en-US,en" will be used. This value will be
  // ignored if |cache_path| matches the CefSettings.cache_path value.
  ///
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: form closes automatically

Post by Kazann117 »


I don’t understand what, I just can’t understand why my browser closes when I open the site
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: form closes automatically

Post by salvadordf »

Try loading that website normally without a custom request context.
If it works, then try to use a custom request context but create it with empty parameters :

Code: Select all

TempContext := TCefRequestContextRef.New('', '', False, False, False, False);
If it works, then try a full path to a directory with write privileges for the cache parameter.
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: form closes automatically

Post by Kazann117 »


if use

TempContext := TCefRequestContextRef.New('','',False, False, False, False);
Chromium1.CreateBrowser(CEFWindowParent1,'', TempContext);

then everything works.


but this is not an option I need cookies in a separate folder
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: form closes automatically

Post by Kazann117 »


the most interesting thing is he creates a folder with cookies, and then the form just closes
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: form closes automatically

Post by Kazann117 »

helped the full path everything works, but it's not convenient since everyone has different drives
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: form closes automatically

Post by Kazann117 »

Now the site does not crash, but cookies do not load back, although all data has been recorded
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: form closes automatically

Post by salvadordf »

You have to set GlobalCEFApp.RootCache too. It's a new setting that needs to be used as a common parent for all the cache directories.

These are the code comments for GlobalCEFApp.RootCache :

Code: Select all

  ///
  // The root directory that all CefSettings.cache_path and
  // CefRequestContextSettings.cache_path values must have in common. If this
  // value is empty and CefSettings.cache_path is non-empty then this value will
  // default to the CefSettings.cache_path value. Failure to set this value
  // correctly may result in the sandbox blocking read/write access to the
  // cache_path directory.
  ///
These are the code comments for the cache parameter in TCefRequestContextRef.New :

Code: Select all

  ///
  // The location where cache data for this request context will be stored on
  // disk. If non-empty this must be either equal to or a child directory of
  // CefSettings.root_cache_path. If empty then browsers will be created in
  // "incognito mode" where in-memory caches are used for storage and no data is
  // persisted to disk. HTML5 databases such as localStorage will only persist
  // across sessions if a cache path is specified. To share the global browser
  // cache and related configuration set this value to match the
  // CefSettings.cache_path value.
  ///
These are the code comments for GlobalCEFApp.cache :

Code: Select all

  ///
  // The location where data for the global browser cache will be stored on
  // disk. If non-empty this must be either equal to or a child directory of
  // CefSettings.root_cache_path. If empty then browsers will be created in
  // "incognito mode" where in-memory caches are used for storage and no data is
  // persisted to disk. HTML5 databases such as localStorage will only persist
  // across sessions if a cache path is specified. Can be overridden for
  // individual CefRequestContext instances via the
  // CefRequestContextSettings.cache_path value.
  ///
Please, make sure you use the latest version of CEF4Delphi because GlobalCEFApp.RootCache had an issue a few weeks ago.
Post Reply