-
Notifications
You must be signed in to change notification settings - Fork 5
Embedded Browser
- Cef - Chromium Embedded Framework (Aardvark Platforms Default)
- Gecko - Browser Engine used in Firefox
- WebKit - Browser Engine used in Apples Safari
- KHTML - Browser Engine used in KDEs Konqueror (Ancestor of WebKit, Chromium, Opera,...)
- EdgeHTML/WebView - UWP Edge Browser Control, Win10 only, not tested with Aardvark Platform
- WebBrowser - Winforms Internet Explorer Control, doesn't work with Aardvark Platform
Features: Development Console, render browser output to texture
Example in aardvark-platform/template MediaUI.fs
Init at the start of your program:
Xilium.CefGlue.ChromiumUtilities.UnpackCef()
Aardvark.UI.Chromium.init args
Winforms-Control:
use ctrl = new Aardvark.UI.AardvarkCefBrowser()
ctrl.StartUrl <- "http://orf.at/"
ctrl.Dock <- DockStyle.Fill
Example code see CefGlueDemo/DemoApp.cs at XiliumCefGlue
or Aardvark.Cef.WinForms/ChromiumStuff.fs from aardvark.media
NuGet Packages:
Another.Unofficial.Xilium.CefGlue.UnpackNativeDependencies
Another.Unofficial.Xilium.CefGlue.WindowsForms
Init at the start of your program:
using Xilium.CefGlue;
class MyCeffApp : CefApp {}
...
ChromiumUtilities.UnpackCef()
CefRuntime.Load();
var settings = new CefSettings();
settings.MultiThreadedMessageLoop = (CefRuntime.Platform == CefRuntimePlatform.Windows);
var mainArgs = new CefMainArgs(args);
var app = new MyCeffApp();
var code = CefRuntime.ExecuteProcess(new CefMainArgs(args), app, IntPtr.Zero);
if (code == -1)
CefRuntime.Initialize(mainArgs, settings, app, IntPtr.Zero);
Setup Winform Control:
class MyCefBrowser : CefWebBrowser {}
...
var ctrl = new MyCefBrowser();
ctrl.Dock = DockStyle.Fill;
ctrl.StartUrl = "http://orf.at";
NuGet packages:
32bit: Geckofx45
64bit: Geckofx45.64
Gecko.Xpcom.Initialize("Firefox");
var browser = new Gecko.GeckoWebBrowser() {
Dock = DockStyle.Fill,
Navigate("http://orf.at")
}
DPS destroys and recreates its Forms. As a result Chromium crashes and Gecko refuses to show anything.
Fix: Detach and reattach browser control
class MyForm : WeifenLuo.WinFormsUI.Docking.DockContent
...
myForm.DockStateChanged += new EventHandler(DockedBrowser_DockStateChanged);
myForm.HandleDestroyed += new EventHandler(DockedBrowser_HandleDestroyed);
...
void DockedBrowser_HandleDestroyed(object sender, EventArgs e) {
m_myBrowserCtrl.Parent = null;
}
void DockedBrowser_DockStateChanged(object sender, EventArgs e) {
if (IsHandleCreated) {
m_myBrowserCtrl.Parent = FindForm()
m_myBrowserCtrl.BringToFront();
}
}
CefRuntime starts the current executable a second time to initiate its child process. The VS hosting process breaks this.
There are two solutions to fix this:
- Disable "Visual Studio hosting process" in the projects properties under Debug
- Use a different executable to start the child process (HOWTO in progress!)