pkg/60579: www/firefox: WebGL does not work on NetBSD

"Izumi Tsutsui via gnats" <[email protected]>
Newsgroups gmane.os.netbsd.devel.pkgsrc.bugs
Message-ID <[email protected]>
>Number:         60579
>Category:       pkg
>Synopsis:       www/firefox: WebGL does not work on NetBSD
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 13 18:55:00 +0000 2026
>Originator:     Izumi Tsutsui
>Release:        NetBSD 11.0
>Organization:
>Environment:
System: NetBSD mirage 11.0 NetBSD 11.0 (GENERIC) #0: Thu Jul 30 15:23:12 UTC 2026 [email protected]:/usr/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:

WebGL is currently disabled by default in pkgsrc Firefox on NetBSD.

If WebGL is enabled by setting "webgl.disabled" to false in about:config
and a WebGL page is opened, about:support shows the following messages
in the Assert entries of the graphics failure log:

  MethodDispatcher<7> not found. Please file a bug!
  MethodDispatcher<26> not found. Please file a bug!

The method IDs are assigned in dom/canvas/WebGLMethodDispatcher.h and
it uses __COUNTER__ for the IDs. On the other hand, preprocessor output
on NetBSD shows that the generated IDs start at 1, rather than 0 that
the firefox may expect.

This may be caused by some NetBSD system-provided header file uses
__COUNTER__ in __CTASSERT() etc. (see <sys/cdefs.h>)

>How-To-Repeat:

Build and install pkgsrc www/firefox 153.0.1 on NetBSD.

Set
```
  webgl.disabled = false
```
in about:config, restart Firefox, and open a WebGL page, for example:

 https://weather.yahoo.co.jp/weather/zoomradar/

Then check the graphics section in about:support.

>Fix:

The attached patch makes the method IDs start at 0 regardless of the
previous value of __COUNTER__, and removes the pkgsrc preference that
disables WebGL on NetBSD.

With this change, the above messages disappear and WebGL pages work on
both NetBSD/i386 11.0 and NetBSD/amd64 11.0.

 https://github.com/tsutsui/pkgsrc/commit/41d8a7ac0ab43db8b4f9694233b1466f5b208703

---
diff --git a/www/firefox/Makefile b/www/firefox/Makefile
index 0bd5dd30329b..4adae82246ee 100644
--- a/www/firefox/Makefile
+++ b/www/firefox/Makefile
@@ -6,6 +6,7 @@ MOZ_BRANCH_MINOR=	.1
 
 DISTNAME=	firefox-${FIREFOX_VER}.source
 PKGNAME=	${DISTNAME:S/.source//:S/b/beta/:S/esr//}
+PKGREVISION=	1
 CATEGORIES=	www
 MASTER_SITES+=	${MASTER_SITE_MOZILLA:=firefox/releases/${FIREFOX_VER}/source/}
 MASTER_SITES+=	${MASTER_SITE_MOZILLA_ALL:=firefox/releases/${FIREFOX_VER}/source/}
diff --git a/www/firefox/distinfo b/www/firefox/distinfo
index b686f0135705..aad5de53b532 100644
--- a/www/firefox/distinfo
+++ b/www/firefox/distinfo
@@ -6,13 +6,14 @@ Size (firefox-153.0.1.source.tar.xz) = 803443372 bytes
 BLAKE2s (nodejs-output-153.0.tgz) = 55a9ae8d1b743f57148a3b763bce2bc9afe2bd902f5b5d6a07a3e597c569aca1
 SHA512 (nodejs-output-153.0.tgz) = 2513c4c47c9bb619a1702a36b8ec316a6c48d6b641656abf86ff33c5ae9e146721947b26a3a1af8295a005daeffb0c77e5f82f36ca9a717decc6850b3518c275
 Size (nodejs-output-153.0.tgz) = 247910 bytes
-SHA1 (patch-browser_app_profile_firefox.js) = 44c1fe360411e5946824aa4c814eaf5929e3648d
+SHA1 (patch-browser_app_profile_firefox.js) = 3e63f89e7a9ded4a3041232754db0c5f3d9d3d32
 SHA1 (patch-build_gn__processor.py) = 078f773104bf4c1b30584564aefe365db6ba6daf
 SHA1 (patch-build_moz.configure_init.configure) = 65deb3c233df0aab81eb1fca05d708e5a4ed169a
 SHA1 (patch-build_moz.configure_rust.configure) = 25ddfacd29cebbc6db005dbe61a2a7446d480678
 SHA1 (patch-config_gcc-stl-wrapper.template.h) = f2d19349e2e93c0f82db0a76124103e6ae6bba9d
 SHA1 (patch-config_makefiles_rust.mk) = 25eb2d4c99ace2b215917490f28ceb90ab90145f
 SHA1 (patch-dom_base_nsAttrName.h) = ac7ba441a3b27df2855cf2673eea36b1cb44ad49
+SHA1 (patch-dom_canvas_WebGLMethodDispatcher.h) = 77780babe30c9ee052c55e92801907d8befa9bde
 SHA1 (patch-dom_media_mediacapabilities_MediaCapabilitiesValidation.cpp) = 2f471067387bb63d530ba1299f0542d3b3a785b6
 SHA1 (patch-dom_media_webrtc_libwebrtc__overrides_moz.build) = a2ff7cf1e6aaf888ee78581d89c7e658f46c3fcd
 SHA1 (patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp) = b93b4c6367bd2fb3d1868ab7d97ca56c100be414
diff --git a/www/firefox/patches/patch-browser_app_profile_firefox.js b/www/firefox/patches/patch-browser_app_profile_firefox.js
index 655f5b7c7650..8f76963dd131 100644
--- a/www/firefox/patches/patch-browser_app_profile_firefox.js
+++ b/www/firefox/patches/patch-browser_app_profile_firefox.js
@@ -3,9 +3,9 @@ $NetBSD: patch-browser_app_profile_firefox.js,v 1.25 2026/07/16 13:11:48 ryoon E
 This patch modifies default Firefox settings - see the comments above
 each one.
 
---- browser/app/profile/firefox.js.orig	2025-10-03 13:17:55.000000000 +0000
+--- browser/app/profile/firefox.js.orig	2026-07-27 13:36:24.000000000 +0000
 +++ browser/app/profile/firefox.js
-@@ -2842,6 +2842,39 @@ pref("app.normandy.onsync_skew_sec", 600
+@@ -2907,6 +2907,36 @@ pref("app.normandy.onsync_skew_sec", 600
  pref("toolkit.coverage.enabled", false);
  pref("toolkit.coverage.endpoint.base", "https://coverage.mozilla.org");
  
@@ -30,9 +30,6 @@ each one.
 +pref("midi.prompt.testing", true);
 +pref("media.navigator.permission.disabled", true);
 +
-+// Avoid runtime error from WebGL for NetBSD systems. webgl.out-of-process was removed.
-+pref("webgl.disabled", true);
-+
 +// Avoid unfunctional video and audio codecs
 +pref("media.allow-audio-non-utility", true);
 +
diff --git a/www/firefox/patches/patch-dom_canvas_WebGLMethodDispatcher.h b/www/firefox/patches/patch-dom_canvas_WebGLMethodDispatcher.h
new file mode 100644
index 000000000000..9bc3b9928d31
--- /dev/null
+++ b/www/firefox/patches/patch-dom_canvas_WebGLMethodDispatcher.h
@@ -0,0 +1,25 @@
+$NetBSD$
+
+- Work around broken WebGL method dispatch on NetBSD.
+
+--- dom/canvas/WebGLMethodDispatcher.h.orig	2026-07-27 13:13:11.000000000 +0000
++++ dom/canvas/WebGLMethodDispatcher.h
+@@ -31,7 +31,18 @@ class WebGLMethodDispatcher
+ 
+ // Defines each method the WebGLMethodDispatcher handles.  The COUNTER value
+ // is used as a cross-process ID for each of the methods.
++#ifdef __NetBSD__
++// XXX: NetBSD system headers use __COUNTER__ in __CTASSERT(), so
++//      __COUNTER__ may already have been incremented when this header is
++//      included.  Normalize the method IDs so that they start at zero.
++constexpr size_t kWebGLMethodDispatcherCounterBase = __COUNTER__ + 1;
++
++#define DEFINE_ASYNC(_METHOD)                                      \
++  DEFINE_METHOD_DISPATCHER(                                        \
++      __COUNTER__ - kWebGLMethodDispatcherCounterBase, _METHOD, 0)
++#else
+ #define DEFINE_ASYNC(_METHOD) DEFINE_METHOD_DISPATCHER(__COUNTER__, _METHOD, 0)
++#endif
+ 
+ DEFINE_ASYNC(HostWebGLContext::CreateBuffer)
+ DEFINE_ASYNC(HostWebGLContext::CreateFramebuffer)

---
Izumi Tsutsui
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.