Bug 2062055 - [firefox-devtools-mcp] resolve geckodriver on all platforms so aarch64 Linux can launch - #170
Open
shoemoney wants to merge 1 commit into
Open
Conversation
…orms so aarch64 Linux can launch
The normal launch path built `new firefox.ServiceBuilder()` with no driver
path on every non-Windows platform, so selenium-webdriver fell back to its
bundled selenium-manager. The Linux selenium-manager shipped with
selenium-webdriver 4.36.0 is an x86-64 binary:
node_modules/selenium-webdriver/bin/linux/selenium-manager:
ELF 64-bit LSB pie executable, x86-64, static-pie linked, stripped
On an aarch64 host it cannot execute, and the session fails immediately with
"Unable to obtain browser driver" even when a native aarch64 geckodriver is
in PATH.
This was the only one of four ServiceBuilder sites not already resolving the
path itself. The Android and --connect-existing paths call findGeckodriver()
unconditionally, and the Windows branch of this same block already did too
(Bug 2040849). This makes the remaining branch consistent with them.
findGeckodriver() checks PATH, then the selenium cache, then downloads a
platform-correct binary via the geckodriver package, which is a regular
dependency. Verified on macOS that Firefox is still discovered without
--firefox-path, since passing a driver path also disables selenium-manager's
browser lookup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
connect()built the geckodriver service without a driver path on every non-Windows platform:With no path, selenium-webdriver invokes its bundled
selenium-manager. The Linux binary shipped withselenium-webdriver@4.36.0is x86-64 only:So on aarch64 the session dies before Firefox is ever contacted — and a native geckodriver sitting in
PATHdoes not help, because nothing on this branch looks there.Confirming the report
@masato.kojima's diagnosis is exactly right, and I could reproduce it on real hardware. Raspberry Pi, aarch64 Ubuntu 24.04, official Mozilla
linux64-aarch64Firefox, geckodriver 0.37.1 aarch64 inPATH, unmodifiedmainate04a955:Same error string as the bug, and it fails in 12ms — before any browser work, which is the tell that this is the driver lookup and not Firefox.
The change
Resolve the path on every platform. This was the only one of four
ServiceBuildersites not already doing so — the Android path and the--connect-existingpath both callfindGeckodriver()unconditionally, and the Windows branch of this very block already did. Theelsewas the outlier.findGeckodriver()checksPATH, then~/.cache/selenium/geckodriver, then downloads a platform-correct binary via thegeckodriverpackage (a regular dependency at6.0.2). None of those tiers can produce a wrong-architecture binary.The diff on the source is net −12/+11 — it deletes the branch rather than adding one.
Verification
Same Pi, same Firefox, same geckodriver, one-file patch:
main(e04a955)Unable to obtain browser driver.Gecko/20100101 Firefox/154.0The regression I was worried about, and checked. Passing a driver path also stops selenium-webdriver calling
getBinaryPaths(), which is how selenium-manager discovers the Firefox binary — andsetBinary()is only called here when--firefox-pathis given. So the question was whether geckodriver finds Firefox on its own. On macOS, launching with no--firefox-path:It does, and it is ~3.8s faster because the selenium-manager round trip is gone. On the Pi it passes both with and without
--firefox-path.Full suite on macOS, including the integration tests against a real Firefox:
Test
One unit test in
tests/firefox/core.test.ts, using the existing mocked-Selenium harness. It captures theServiceBuilderconstructor argument, which is the thing that was missing. On unmodifiedmain:That
undefinedis the bug — it is the argument selenium-manager gets invoked in place of.I did not add an integration test for this: reproducing it requires an aarch64 Linux host, and CI runs x86-64, so the test would pass there for the wrong reason and prove nothing. The hardware evidence above is in this PR instead.
Note
The bug is still
UNCONFIRMEDin Bugzilla. Everything above reproduces it on real aarch64 hardware, so it can be confirmed if that is useful — happy to add the details there.中文说明
在非 Windows 平台上,
connect()构造 geckodriver 服务时未传入驱动路径,导致 selenium-webdriver 回退到其内置的selenium-manager。而selenium-webdriver@4.36.0附带的 Linux 版selenium-manager仅为 x86-64 二进制,在 aarch64 主机上无法执行(Exec format error),因此会话在接触 Firefox 之前就以Unable to obtain browser driver失败——即使PATH中已存在原生 aarch64 geckodriver 也无济于事。本改动在所有平台上都自行解析 geckodriver 路径。这是本仓库四处
ServiceBuilder调用中唯一尚未这样做的一处:Android 路径与--connect-existing路径均已无条件调用findGeckodriver(),同一代码块的 Windows 分支也是如此。在树莓派(aarch64 Ubuntu 24.04、官方 aarch64 Firefox 154.0、geckodriver 0.37.1)上验证:
main失败(12ms),打上本补丁后通过(3411ms)。同时在 macOS 上确认——由于传入驱动路径也会跳过 selenium-manager 对 Firefox 二进制的查找——在不指定--firefox-path时 Firefox 仍能被正确发现,且启动快约 3.8 秒。macOS 全量测试(含针对真实 Firefox 的集成测试):50 个文件、650 个测试全部通过。