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.

Windows 7

Post Reply
Det20
Posts: 38
Joined: Fri Mar 10, 2017 3:11 pm

Windows 7

Post by Det20 »

Some of my users have problems starting my app (using the latest CEF4Delphi) under Windows 7, the EXE is started over and over again if i start a HTML5 Video. Is there any knowing problem under Systems < Windows 10? Or is every Windows Version > XP support?

And, what i also see is, that some users have install a anonymous proxy (Hotspot Shield). Chrome is not installed and if i install Chrome (the Backend from Google), this Plugin is automatically used by Chrome (i can see the "Disable" Button into Chrome Settings). Can i disable autoload Plugins?
User avatar
salvadordf
Posts: 4052
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Windows 7

Post by salvadordf »

Det20 wrote: Thu Mar 23, 2017 3:12 pm Some of my users have problems starting my app (using the latest CEF4Delphi) under Windows 7, the EXE is started over and over again if i start a HTML5 Video. Is there any knowing problem under Systems < Windows 10? Or is every Windows Version > XP support?
I watched an HTML5 video using the minibrowser demo in Windows 7 (32bit) from this web page : https://www.w3schools.com/html/html5_video.asp
While playing the video I could only see 3 processes created automatically by CEF3.

I can only guess that there's something wrong in the code inside your DPR file. Make sure you have something like this (notice the if..then clause) :

Code: Select all

  GlobalCEFApp := TCefApplication.Create;
  if GlobalCEFApp.StartMainProcess then
    begin
      Application.Initialize;
      Application.MainFormOnTaskbar := True;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    end;
  GlobalCEFApp.Free;  
and not like this (without the if..then clause) :

Code: Select all

  GlobalCEFApp := TCefApplication.Create;
  GlobalCEFApp.StartMainProcess;
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
  GlobalCEFApp.Free;
Det20 wrote: Thu Mar 23, 2017 3:12 pm And, what i also see is, that some users have install a anonymous proxy (Hotspot Shield). Chrome is not installed and if i install Chrome (the Backend from Google), this Plugin is automatically used by Chrome (i can see the "Disable" Button into Chrome Settings). Can i disable autoload Plugins?
TChromium has several properties to configure proxies : ProxyType, ProxyServer, ProxyPort, ProxyUsername, ProxyPassword, ProxyScriptURL, ProxyByPassList.
What those properties do is modify the preferences as described here : https://www.chromium.org/administrators ... st-3#Proxy

The default value is CEF_PROXYTYPE_DIRECT which means "Never use a proxy" but if you want to make sure it's disabled, set TChromium.ProxyType := CEF_PROXYTYPE_DIRECT; every time you create a TChromium component.
Det20
Posts: 38
Joined: Fri Mar 10, 2017 3:11 pm

Re: Windows 7

Post by Det20 »

CEF_PROXYTYPE_SYSTEM = Use Windows Settings? If yes, this seems to be the best because if IE/Chrome can use internet, CEF4 can use it, too.

This is the way of my DPR. If Chromium is available, i set "ChromiumSupport" in my application. If this is set, i use Chromium, otherwise i use IE.

GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.DeleteCache := true;
GlobalCEFApp.DeleteCookies := true;
GlobalCEFApp.FlashEnabled := true;
GlobalCEFApp.EnableSpeechInput := false;
GlobalCEFApp.EnableMediaStream := true;

StartedWithChromium := Assigned(GlobalCEFApp) and GlobalCEFApp.StartMainProcess;

Application.Initialize;
Application.CreateForm(TfrmMain, frmMain);
frmMain.ChromiumSupport := StartedWithChromium;
Application.Run;
Try
If Assigned(GlobalCEFApp) then GlobalCEFApp.Free;
Except
End;
User avatar
salvadordf
Posts: 4052
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Windows 7

Post by salvadordf »

Det20 wrote: Fri Mar 24, 2017 1:43 pm CEF_PROXYTYPE_SYSTEM = Use Windows Settings? If yes, this seems to be the best because if IE/Chrome can use internet, CEF4 can use it, too.
That's correct, CEF_PROXYTYPE_SYSTEM means "Use system proxy settings" or "Use windows settings".

Remember that sometimes CEF3 creates delays during application startup due to network proxy resolution.
Read more about it in the 20th question of this FAQ :
http://magpcss.org/ceforum/viewtopic.php?f=6&t=10567
Det20 wrote: Fri Mar 24, 2017 1:43 pm This is the way of my DPR. If Chromium is available, i set "ChromiumSupport" in my application. If this is set, i use Chromium, otherwise i use IE.

GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.DeleteCache := true;
GlobalCEFApp.DeleteCookies := true;
GlobalCEFApp.FlashEnabled := true;
GlobalCEFApp.EnableSpeechInput := false;
GlobalCEFApp.EnableMediaStream := true;

StartedWithChromium := Assigned(GlobalCEFApp) and GlobalCEFApp.StartMainProcess;

Application.Initialize;
Application.CreateForm(TfrmMain, frmMain);
frmMain.ChromiumSupport := StartedWithChromium;
Application.Run;
Try
If Assigned(GlobalCEFApp) then GlobalCEFApp.Free;
Except
End;
CEF4Delphi must be initialized with an if..then clause because the creation of subprocesses depends on that structure.

The CEF3 application structure is explained here :
https://bitbucket.org/chromiumembedded/ ... -structure

CEF4Delphi simplifies all that into a single class (TCEFApplication) and a function (StartMainProcess)

The subprocesses will also execute the GobalCEFApp creation and initialization but StartMainProcess will return FALSE for them (True for the main application process). That way, only the main application process will get to the "Application.Initialize; ... Application.Run;" part.

In the previous link about the CEF3 application structure this is controlled by the result of CefExecuteProcess but it does the same thing.

If your application needs to detect if Chromium is available you can check if libcef.dll exists before creating GlobalCEFApp. Something like this :

Code: Select all

if FileExists('libcef.dll') then
  begin
    GlobalCEFApp := TCefApplication.Create;
    GlobalCEFApp.DeleteCache   := true;
    GlobalCEFApp.DeleteCookies := true;
    GlobalCEFApp.FlashEnabled  := true;
    GlobalCEFApp.EnableSpeechInput := false;
    GlobalCEFApp.EnableMediaStream := true;
    
    if GlobalCEFApp.StartMainProcess then
      begin
        Application.Initialize;
        Application.CreateForm(TfrmMain, frmMain);
        frmMain.ChromiumSupport := True;
        Application.Run;      
      end;
      
    GlobalCEFApp.Free;  
  end
 else
  begin
    Application.Initialize;
    Application.CreateForm(TfrmMain, frmMain);
    frmMain.ChromiumSupport := False;
    Application.Run;  
  end; 
Det20
Posts: 38
Joined: Fri Mar 10, 2017 3:11 pm

Re: Windows 7

Post by Det20 »

But what happens if i start the application the way i do? I think it's only to prevent the application to start over and over again, because GlobalCEFApp.StartMainProcess return false if application is already startet.

Maybe it's a good idea to make CheckCEFLibrary public (for use without create the class).
User avatar
salvadordf
Posts: 4052
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Windows 7

Post by salvadordf »

Det20 wrote: Fri Mar 24, 2017 2:55 pm Ok, but what happens if i start the application the way i do? I think it's only to prevent the application to start over and over again.
By default, TCEFApplication is using the same EXE for the main process and for the subprocesses, as Chrome does.

That means that all of them will execute the code of your DPR file.

This is valid as long as only the main process initializes your application (the "Application.Initialize; ... Application.Run;" part)
If you allow all subprocesses to initlialize your application then you'll have the problem your users reported : multiple copies of the app running at the same time.

To avoid this problem, CEF4Delphi returns a different value in StartMainProcess : True for the main process and False for the subprocesses.
With a different value, only the main process initializes the application while the subprocesses remain inside the StartMainProcess function doing whatever they have to do (rendering, flash, etc) and then return False, skipping the initialization part.
Det20 wrote: Fri Mar 24, 2017 2:55 pm Maybe it's a good idea to make CheckCEFLibrary public (for use without create the class).
I'll do that for the next version.
Det20
Posts: 38
Joined: Fri Mar 10, 2017 3:11 pm

Re: Windows 7

Post by Det20 »

Thank you. I'll wait for the changes and then re-try it.
What do you think: WIll my "will not play HTML5 videos"-Problem will be fixed if i change the DPR to your way? Or is this another problem?
User avatar
salvadordf
Posts: 4052
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Windows 7

Post by salvadordf »

This will fix the problem with multiple application copies running at the same time.

Test it in a controlled environment to check if HTML5 video plays correctly. Remember that the CEF3 binaries from spotify only support open source codecs.
Post Reply