mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-15 15:55:56 +01:00
Added initialization workaround for Linux demos thanks to Christoph Schneider
This commit is contained in:
parent
f1f638ba18
commit
e2ffd8519c
@ -50,6 +50,12 @@ begin
|
||||
GlobalCEFApp.EnableHighDPISupport := True;
|
||||
GlobalCEFApp.ExternalMessagePump := True;
|
||||
GlobalCEFApp.MultiThreadedMessageLoop := False;
|
||||
|
||||
// This is a workaround to fix a Chromium initialization crash.
|
||||
// The current FMX solution to initialize CEF with a loader unit
|
||||
// creates a race condition with the media key controller in Chromium.
|
||||
GlobalCEFApp.DisableFeatures := 'HardwareMediaKeyHandling';
|
||||
|
||||
GlobalCEFApp.StartSubProcess;
|
||||
DestroyGlobalCEFApp;
|
||||
end.
|
||||
|
@ -47,25 +47,16 @@ uses
|
||||
// project.
|
||||
// Read the answer to this question for more more information :
|
||||
// https://stackoverflow.com/questions/52103407/changing-the-initialization-order-of-the-unit-in-delphi
|
||||
System.SyncObjs,
|
||||
uCEFApplication, uCEFConstants, uCEFWorkScheduler;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
CEFContextInitEvent : TEvent;
|
||||
|
||||
procedure GlobalCEFApp_OnScheduleMessagePumpWork(const aDelayMS : int64);
|
||||
begin
|
||||
if (GlobalCEFWorkScheduler <> nil) then
|
||||
GlobalCEFWorkScheduler.ScheduleMessagePumpWork(aDelayMS);
|
||||
end;
|
||||
|
||||
procedure GlobalCEFApp_OnContextInitialized;
|
||||
begin
|
||||
CEFContextInitEvent.SetEvent;
|
||||
end;
|
||||
|
||||
procedure InitializeGlobalCEFApp;
|
||||
begin
|
||||
// TCEFWorkScheduler will call cef_do_message_loop_work when
|
||||
@ -83,28 +74,23 @@ begin
|
||||
GlobalCEFApp.MultiThreadedMessageLoop := False;
|
||||
GlobalCEFApp.DisableZygote := True;
|
||||
GlobalCEFApp.OnScheduleMessagePumpWork := GlobalCEFApp_OnScheduleMessagePumpWork;
|
||||
GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized;
|
||||
GlobalCEFApp.BrowserSubprocessPath := 'FMXExternalPumpBrowser2_sp';
|
||||
GlobalCEFApp.LogFile := 'debug.log';
|
||||
GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO;
|
||||
|
||||
if GlobalCEFApp.StartMainProcess then
|
||||
begin
|
||||
// Wait until the context is initialized
|
||||
CEFContextInitEvent.WaitFor(10000);
|
||||
// Now we can create the GlobalCEFWorkScheduler background thread
|
||||
GlobalCEFWorkScheduler.CreateThread;
|
||||
end;
|
||||
// This is a workaround to fix a Chromium initialization crash.
|
||||
// The current FMX solution to initialize CEF with a loader unit
|
||||
// creates a race condition with the media key controller in Chromium.
|
||||
GlobalCEFApp.DisableFeatures := 'HardwareMediaKeyHandling';
|
||||
|
||||
GlobalCEFApp.StartMainProcess;
|
||||
GlobalCEFWorkScheduler.CreateThread;
|
||||
end;
|
||||
|
||||
initialization
|
||||
CEFContextInitEvent := TEvent.Create;
|
||||
InitializeGlobalCEFApp;
|
||||
|
||||
finalization
|
||||
if (GlobalCEFWorkScheduler <> nil) then GlobalCEFWorkScheduler.StopScheduler;
|
||||
DestroyGlobalCEFApp;
|
||||
DestroyGlobalCEFWorkScheduler;
|
||||
CEFContextInitEvent.Free;
|
||||
|
||||
end.
|
||||
|
@ -7,10 +7,11 @@
|
||||
<Unit0>
|
||||
<Filename Value="OSRExternalPumpBrowser.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="31"/>
|
||||
<CursorPos X="20" Y="72"/>
|
||||
<UsageCount Value="91"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
@ -20,15 +21,15 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="uOSRExternalPumpBrowser"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="608"/>
|
||||
<CursorPos X="64" Y="626"/>
|
||||
<TopLine Value="189"/>
|
||||
<CursorPos X="4" Y="199"/>
|
||||
<UsageCount Value="91"/>
|
||||
<Bookmarks Count="6">
|
||||
<Item0 Y="723" ID="2"/>
|
||||
<Item1 X="9" Y="620" ID="3"/>
|
||||
<Item2 X="13" Y="333" ID="9"/>
|
||||
<Item3 Y="708" ID="8"/>
|
||||
<Item4 X="41" Y="298" ID="7"/>
|
||||
<Item0 Y="704" ID="2"/>
|
||||
<Item1 X="9" Y="602" ID="3"/>
|
||||
<Item2 X="13" Y="315" ID="9"/>
|
||||
<Item3 Y="689" ID="8"/>
|
||||
<Item4 X="41" Y="280" ID="7"/>
|
||||
<Item5 X="52" Y="187" ID="1"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
@ -830,123 +831,127 @@
|
||||
<Define0 Value="UseCthreads"/>
|
||||
<Define1 Value="EnabledGtkThreading"/>
|
||||
</OtherDefines>
|
||||
<JumpHistory Count="29" HistoryIndex="28">
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="91" Column="24" TopLine="59"/>
|
||||
<Caret Line="708" TopLine="682"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="696" Column="37" TopLine="691"/>
|
||||
<Caret Line="709" Column="22" TopLine="682"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="310" TopLine="286"/>
|
||||
<Caret Line="706" Column="39" TopLine="682"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="708" TopLine="682"/>
|
||||
<Caret Line="72" Column="32" TopLine="54"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="709" Column="22" TopLine="682"/>
|
||||
<Caret Line="117" Column="33" TopLine="92"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="706" Column="39" TopLine="682"/>
|
||||
<Caret Line="88" Column="22" TopLine="61"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="72" Column="32" TopLine="54"/>
|
||||
<Caret Line="328" Column="58" TopLine="308"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="117" Column="33" TopLine="92"/>
|
||||
<Caret Line="216" Column="77" TopLine="205"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="88" Column="22" TopLine="61"/>
|
||||
<Caret Line="87" Column="22" TopLine="60"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="328" Column="58" TopLine="308"/>
|
||||
<Caret Line="73" Column="13" TopLine="63"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="216" Column="77" TopLine="205"/>
|
||||
<Caret Line="410" Column="3" TopLine="406"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="87" Column="22" TopLine="60"/>
|
||||
<Caret Line="277" Column="73" TopLine="237"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="73" Column="13" TopLine="63"/>
|
||||
<Caret Line="86" Column="24" TopLine="81"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="410" Column="3" TopLine="406"/>
|
||||
<Caret Line="768" TopLine="54"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="277" Column="73" TopLine="237"/>
|
||||
<Caret Line="195" Column="47" TopLine="172"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="86" Column="24" TopLine="81"/>
|
||||
<Caret Line="220" Column="36" TopLine="197"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="768" TopLine="54"/>
|
||||
<Caret Line="221" Column="51" TopLine="197"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="195" Column="47" TopLine="172"/>
|
||||
<Caret Line="235" Column="62" TopLine="208"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="220" Column="36" TopLine="197"/>
|
||||
<Caret Line="240" Column="47" TopLine="205"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="221" Column="51" TopLine="197"/>
|
||||
<Caret Line="331" TopLine="310"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="235" Column="62" TopLine="208"/>
|
||||
<Caret Line="722" TopLine="713"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="240" Column="47" TopLine="205"/>
|
||||
<Caret Line="96" TopLine="74"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="331" TopLine="310"/>
|
||||
<Caret Line="95" TopLine="73"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="722" TopLine="713"/>
|
||||
<Caret Line="317" Column="82" TopLine="291"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="96" TopLine="74"/>
|
||||
<Caret Line="79" Column="15" TopLine="65"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="95" TopLine="73"/>
|
||||
<Caret Line="620" Column="34" TopLine="596"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="317" Column="82" TopLine="291"/>
|
||||
<Filename Value="OSRExternalPumpBrowser.lpr"/>
|
||||
<Caret Line="72" Column="20" TopLine="31"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="79" Column="15" TopLine="65"/>
|
||||
<Caret Line="689" TopLine="644"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="620" Column="34" TopLine="596"/>
|
||||
<Caret Line="687" Column="3" TopLine="644"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="231" TopLine="174"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
|
@ -193,21 +193,12 @@ uses
|
||||
Math, gtk2, glib2, gdk2, gtk2proc, gtk2int,
|
||||
uCEFMiscFunctions, uCEFApplication, uCEFBitmapBitBuffer, uCEFWorkScheduler;
|
||||
|
||||
var
|
||||
CEFContextInitEvent : TSimpleEvent = nil;
|
||||
|
||||
procedure GlobalCEFApp_OnScheduleMessagePumpWork(const aDelayMS : int64);
|
||||
begin
|
||||
if (GlobalCEFWorkScheduler <> nil) then
|
||||
GlobalCEFWorkScheduler.ScheduleMessagePumpWork(aDelayMS);
|
||||
GlobalCEFWorkScheduler.ScheduleMessagePumpWork(aDelayMS);
|
||||
end;
|
||||
|
||||
procedure GlobalCEFApp_OnContextInitialized;
|
||||
begin
|
||||
if (CEFContextInitEvent <> nil) then
|
||||
CEFContextInitEvent.SetEvent;
|
||||
end;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
// TCEFWorkScheduler will call cef_do_message_loop_work when
|
||||
@ -217,7 +208,6 @@ begin
|
||||
// We use CreateDelayed in order to have a single thread in the process while
|
||||
// CEF is initialized.
|
||||
GlobalCEFWorkScheduler := TCEFWorkScheduler.CreateDelayed;
|
||||
CEFContextInitEvent := TSimpleEvent.Create;
|
||||
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.WindowlessRenderingEnabled := True;
|
||||
@ -232,16 +222,8 @@ begin
|
||||
// https://bitbucket.org/chromiumembedded/cef/issues/2964/gpu-is-not-usable-error-during-cef
|
||||
GlobalCEFApp.DisableZygote := True; // this property adds the "--no-zygote" command line switch
|
||||
|
||||
GlobalCEFApp.LogFile := 'debug.log';
|
||||
GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO;
|
||||
|
||||
if GlobalCEFApp.StartMainProcess then
|
||||
begin
|
||||
// Wait until the context is initialized
|
||||
CEFContextInitEvent.WaitFor(5000);
|
||||
// Now we can create the GlobalCEFWorkScheduler background thread
|
||||
GlobalCEFWorkScheduler.CreateThread;
|
||||
end;
|
||||
GlobalCEFApp.StartMainProcess;
|
||||
GlobalCEFWorkScheduler.CreateThread;
|
||||
end;
|
||||
|
||||
function GTKKeyPress(Widget: PGtkWidget; Event: PGdkEventKey; Data: gPointer) : GBoolean; cdecl;
|
||||
@ -694,7 +676,6 @@ procedure TForm1.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
if (FPopUpBitmap <> nil) then FreeAndNil(FPopUpBitmap);
|
||||
if (FResizeCS <> nil) then FreeAndNil(FResizeCS);
|
||||
if (CEFContextInitEvent <> nil) then FreeAndNil(CEFContextInitEvent);
|
||||
end;
|
||||
|
||||
procedure TForm1.FormHide(Sender: TObject);
|
||||
|
@ -2,7 +2,7 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 240,
|
||||
"InternalVersion" : 241,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "88.1.6.0"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user