Skip to content

Commit aeb8a0d

Browse files
committed
Fix sandbox issue on with puppeteer chromium
1 parent 278d674 commit aeb8a0d

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/Utilities/Html/HtmlHelper.Image.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,15 @@ public static async Task<byte[]> RenderHtmlToImageDataAsync(string html, string
181181
{
182182
Headless = true,
183183
Browser = DefaultBrowser!.BrowserType,
184-
ExecutablePath = DefaultBrowser!.ExecutablePath
184+
ExecutablePath = DefaultBrowser!.ExecutablePath,
185+
//PuppeteerSharp.ProcessException : Failed to launch browser! [3163:3163:0420/000113.340765:FATAL:zygote_host_impl_linux.cc(128)] No usable sandbox!
186+
//If you are running on Ubuntu 23.10+ or another Linux distro that has disabled unprivileged user namespaces with AppArmor,
187+
//see https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
188+
//Otherwise see https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the (older) SUID sandbox.
189+
//If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
190+
//https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
191+
//https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md
192+
Args = ["--no-sandbox"]
185193
}))
186194
{
187195
cancellationToken.ThrowIfCancellationRequested();
@@ -274,7 +282,15 @@ public static async Task RenderHtmlToPdfAsync(string html, string path, PdfOptio
274282
{
275283
Headless = true,
276284
Browser = DefaultBrowser!.BrowserType,
277-
ExecutablePath = DefaultBrowser!.ExecutablePath
285+
ExecutablePath = DefaultBrowser!.ExecutablePath,
286+
//PuppeteerSharp.ProcessException : Failed to launch browser! [3163:3163:0420/000113.340765:FATAL:zygote_host_impl_linux.cc(128)] No usable sandbox!
287+
//If you are running on Ubuntu 23.10+ or another Linux distro that has disabled unprivileged user namespaces with AppArmor,
288+
//see https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
289+
//Otherwise see https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the (older) SUID sandbox.
290+
//If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
291+
//https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
292+
//https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md
293+
Args = ["--no-sandbox"]
278294
});
279295

280296
cancellationToken.ThrowIfCancellationRequested();

0 commit comments

Comments
 (0)