public RenderProcess(int pid, string pluginDir, DependencyManager dependencyManager) { keepAliveHandleName = $"BrowserHostRendererKeepAlive{pid}"; ipcChannelName = $"BrowserHostRendererIpcChannel{pid}"; ipc = new IpcBuffer <UpstreamIpcRequest, DownstreamIpcRequest>(ipcChannelName, request => Recieve?.Invoke(this, request)); var processArgs = new RenderProcessArguments() { ParentPid = pid, DalamudAssemblyDir = AppDomain.CurrentDomain.SetupInformation.ApplicationBase, CefAssemblyDir = dependencyManager.GetDependencyPathFor("cef"), CefCacheDir = Path.Combine(Path.GetDirectoryName(pluginDir), "cef-cache"), DxgiAdapterLuid = DxHandler.AdapterLuid, KeepAliveHandleName = keepAliveHandleName, IpcChannelName = ipcChannelName, }; process = new Process(); process.StartInfo = new ProcessStartInfo() { FileName = Path.Combine(pluginDir, "BrowserHost.Renderer.exe"), Arguments = processArgs.Serialise().Replace("\"", "\"\"\""), UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, }; process.OutputDataReceived += (sender, args) => PluginLog.Log($"[Render]: {args.Data}"); process.ErrorDataReceived += (sender, args) => PluginLog.LogError($"[Render]: {args.Data}"); }
private static void Run(RenderProcessArguments args) { waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset, args.KeepAliveHandleName); // Boot up a thread to make sure we shut down if parent dies parentWatchThread = new Thread(WatchParentStatus); parentWatchThread.Start(args.ParentPid); #if DEBUG AppDomain.CurrentDomain.FirstChanceException += (obj, e) => Console.Error.WriteLine(e.Exception.ToString()); #endif var dxRunning = DxHandler.Initialise(args.DxgiAdapterLuid); CefHandler.Initialise(cefAssemblyDir, args.CefCacheDir); ipcBuffer = new IpcBuffer <DownstreamIpcRequest, UpstreamIpcRequest>(args.IpcChannelName, HandleIpcRequest); Console.WriteLine("Notifiying on ready state."); // We always support bitmap buffer transport var availableTransports = FrameTransportMode.BitmapBuffer; if (dxRunning) { availableTransports |= FrameTransportMode.SharedTexture; } ipcBuffer.RemoteRequest <object>(new ReadyNotificationRequest() { availableTransports = availableTransports, }); Console.WriteLine("Waiting..."); waitHandle.WaitOne(); waitHandle.Dispose(); Console.WriteLine("Render process shutting down."); ipcBuffer.Dispose(); DxHandler.Shutdown(); CefHandler.Shutdown(); parentWatchThread.Abort(); }