Hi,
Same diff as for firefox, based on robert@'s code/suggestions. Make
screen sharing use the XSham 1.2 extension which is compatible wih
the default chromium pledge.
ok, comments ?
Index: Makefile
===================================================================
RCS file: /cvs/OpenBSD/ports/www/chromium/Makefile,v
diff -u -p -u -r1.906 Makefile
--- Makefile 20 May 2026 12:17:05 -0000 1.906
+++ Makefile 25 May 2026 08:58:04 -0000
@@ -13,6 +13,7 @@ DPB_PROPERTIES+= lonesome
COMMENT= Chromium browser
V= 148.0.7778.178
+REVISION= 0
DISTNAME= chromium-${V}
Index: patches/patch-third_party_webrtc_modules_desktop_capture_BUILD_gn
===================================================================
RCS file: patches/patch-third_party_webrtc_modules_desktop_capture_BUILD_gn
diff -N patches/patch-third_party_webrtc_modules_desktop_capture_BUILD_gn
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-third_party_webrtc_modules_desktop_capture_BUILD_gn 25 May
2026 08:58:06 -0000
@@ -0,0 +1,12 @@
+Index: third_party/webrtc/modules/desktop_capture/BUILD.gn
+--- third_party/webrtc/modules/desktop_capture/BUILD.gn.orig
++++ third_party/webrtc/modules/desktop_capture/BUILD.gn
+@@ -424,6 +424,8 @@ rtc_library("desktop_capture") {
+
+ "Xrender",
+ "Xtst",
++ "xcb-shm",
++ "X11-xcb",
+ ]
+ }
+
Index:
patches/patch-third_party_webrtc_modules_desktop_capture_linux_x11_x_server_pixel_buffer_cc
===================================================================
RCS file:
/cvs/OpenBSD/ports/www/chromium/patches/patch-third_party_webrtc_modules_desktop_capture_linux_x11_x_server_pixel_buffer_cc,v
diff -u -p -u -r1.6
patch-third_party_webrtc_modules_desktop_capture_linux_x11_x_server_pixel_buffer_cc
---
patches/patch-third_party_webrtc_modules_desktop_capture_linux_x11_x_server_pixel_buffer_cc
11 Aug 2025 08:06:06 -0000 1.6
+++
patches/patch-third_party_webrtc_modules_desktop_capture_linux_x11_x_server_pixel_buffer_cc
25 May 2026 08:58:06 -0000
@@ -1,16 +1,134 @@
+Use XShm 1.2 on OpenBSD for webrtc display sharing
+
Index:
third_party/webrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc
---
third_party/webrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc.orig
+++
third_party/webrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc
-@@ -212,6 +212,12 @@ bool XServerPixelBuffer::Init(XAtomCache* cache, Windo
- void XServerPixelBuffer::InitShm(const XWindowAttributes& attributes) {
- Visual* default_visual = attributes.visual;
- int default_depth = attributes.depth;
-+#if defined(__OpenBSD__)
-+// pledge(2)
-+ RTC_LOG(LS_WARNING) << "Unable to use shmget(2) while using pledge(2). "
-+ "Performance may be degraded.";
-+ return;
+@@ -17,6 +17,13 @@
+ #include <sys/ipc.h>
+ #include <sys/shm.h>
+
++#if defined(__OpenBSD__)
++#include <X11/Xlib-xcb.h>
++#include <xcb/shm.h>
++#include <sys/mman.h>
++#include <unistd.h>
++#endif
++
+ #include <cstdint>
+ #include <vector>
+
+@@ -170,13 +177,24 @@ void XServerPixelBuffer::ReleaseSharedMemorySegment()
+ if (!shm_segment_info_)
+ return;
+ if (xshm_attached_) {
++#if defined(__OpenBSD__)
++ xcb_shm_detach(xcb_connection_, shm_segment_info_->shmseg);
++#else
+ XShmDetach(display_, shm_segment_info_);
++#endif
+ xshm_attached_ = false;
+ }
+ if (shm_segment_info_->shmaddr != nullptr)
++#if defined(__OpenBSD__)
++ munmap(shm_segment_info_->shmaddr, shm_size_);
++#else
+ shmdt(shm_segment_info_->shmaddr);
+- if (shm_segment_info_->shmid != -1)
++#endif
++ if (shm_segment_info_->shmid != -1) {
++#if !defined(__OpenBSD__)
+ shmctl(shm_segment_info_->shmid, IPC_RMID, nullptr);
++#endif
++ }
+ delete shm_segment_info_;
+ shm_segment_info_ = nullptr;
+ }
+@@ -198,8 +216,8 @@ bool XServerPixelBuffer::Init(XAtomCache* cache, Windo
+ icc_profile_ = std::vector<uint8_t>(
+ icc_profile_property.data(),
+ icc_profile_property.data() + icc_profile_property.size());
+- } else {
+- RTC_LOG(LS_WARNING) << "Failed to get icc profile";
++ // } else {
++ // RTC_LOG(LS_WARNING) << "Failed to get icc profile";
+ }
+ }
+
+@@ -224,26 +242,59 @@ void XServerPixelBuffer::InitShm(const XWindowAttribut
+ shm_segment_info_->shmid = -1;
+ shm_segment_info_->shmaddr = nullptr;
+ shm_segment_info_->readOnly = False;
++#if defined(__OpenBSD__)
++ shm_segment_info_->shmseg = XCB_NONE;
+#endif
+ x_shm_image_ = XShmCreateImage(display_, default_visual, default_depth,
+ ZPixmap, nullptr, shm_segment_info_,
+ window_rect_.width(), window_rect_.height());
+ if (x_shm_image_) {
++#if defined(__OpenBSD__)
++ char name[19] = "/webrtc-XXXXXXXXXX";
++ shm_size_ = x_shm_image_->bytes_per_line * x_shm_image_->height;
++ shm_segment_info_->shmid = shm_mkstemp(name);
++ shm_unlink(name);
++#else
+ shm_segment_info_->shmid =
+ shmget(IPC_PRIVATE, x_shm_image_->bytes_per_line *
x_shm_image_->height,
+ IPC_CREAT | 0600);
++#endif
+ if (shm_segment_info_->shmid != -1) {
++#if defined(__OpenBSD__)
++ if (ftruncate(shm_segment_info_->shmid, shm_size_) < 0) {
++ close(shm_segment_info_->shmid);
++ return;
++ }
++ void* shmat_result = mmap(nullptr, shm_size_, PROT_READ | PROT_WRITE,
++ MAP_SHARED | __MAP_NOFAULT,
shm_segment_info_->shmid, 0);
++ if (shmat_result == MAP_FAILED) {
++ close(shm_segment_info_->shmid);
++ return;
++ }
++#else
+ void* shmat_result = shmat(shm_segment_info_->shmid, nullptr, 0);
++#endif
+ if (shmat_result != reinterpret_cast<void*>(-1)) {
+ shm_segment_info_->shmaddr = reinterpret_cast<char*>(shmat_result);
+ x_shm_image_->data = shm_segment_info_->shmaddr;
+
+ XErrorTrap error_trap(display_);
++#if defined(__OpenBSD__)
++ xcb_connection_ = XGetXCBConnection(display_);
++ shm_segment_info_->shmseg = xcb_generate_id(xcb_connection_);
++ xcb_void_cookie_t cookie =
++ xcb_shm_attach_fd_checked(xcb_connection_, shm_segment_info_->shmseg,
++ shm_segment_info_->shmid, 0);
++ if (xcb_request_check(xcb_connection_, cookie) == NULL)
++ xshm_attached_ = true;
++#else
+ xshm_attached_ = XShmAttach(display_, shm_segment_info_);
++#endif
+ XSync(display_, False);
+ if (error_trap.GetLastErrorAndDisable() != 0)
+ xshm_attached_ = false;
+ if (xshm_attached_) {
+- RTC_LOG(LS_VERBOSE)
++ RTC_LOG(LS_WARNING)
+ << "Using X shared memory segment " << shm_segment_info_->shmid;
+ }
+ }
+@@ -263,12 +314,14 @@ void XServerPixelBuffer::InitShm(const XWindowAttribut
+ if (have_pixmaps)
+ have_pixmaps = InitPixmaps(default_depth);
+
++#if !defined(__OpenBSD__)
+ shmctl(shm_segment_info_->shmid, IPC_RMID, nullptr);
+ shm_segment_info_->shmid = -1;
++#endif
+
+- RTC_LOG(LS_VERBOSE) << "Using X shared memory extension v" << major << "."
++ RTC_LOG(LS_WARNING) << "Using X shared memory extension v" << major << "."
+ << minor << " with" << (have_pixmaps ? "" : "out")
+- << " pixmaps.";
++ << " pixmaps." << "fd " << shm_segment_info_->shmid;
+ }
- int major, minor;
- Bool have_pixmaps;
+ bool XServerPixelBuffer::InitPixmaps(int depth) {
Index:
patches/patch-third_party_webrtc_modules_desktop_capture_linux_x11_x_server_pixel_buffer_h
===================================================================
RCS file:
patches/patch-third_party_webrtc_modules_desktop_capture_linux_x11_x_server_pixel_buffer_h
diff -N
patches/patch-third_party_webrtc_modules_desktop_capture_linux_x11_x_server_pixel_buffer_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++
patches/patch-third_party_webrtc_modules_desktop_capture_linux_x11_x_server_pixel_buffer_h
25 May 2026 08:58:06 -0000
@@ -0,0 +1,25 @@
+Index:
third_party/webrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.h
+---
third_party/webrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.h.orig
++++
third_party/webrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.h
+@@ -17,6 +17,10 @@
+ #include <X11/Xlib.h>
+ #include <X11/extensions/XShm.h>
+
++#if defined(__OpenBSD__)
++#include <xcb/xcb.h>
++#endif
++
+ #include <cstdint>
+ #include <vector>
+
+@@ -84,6 +88,10 @@ class XServerPixelBuffer {
+ bool xshm_attached_ = false;
+ bool xshm_get_image_succeeded_ = false;
+ std::vector<uint8_t> icc_profile_;
++#if defined(__OpenBSD__)
++ size_t shm_size_ = 0;
++ xcb_connection_t* xcb_connection_ = nullptr;
++#endif
+ };
+
+ } // namespace webrtc
--
Matthieu Herrb