2025, Oct 24 21:00

Fix Bing Maps Loading Failures in Selenium Chrome: remove --disable-3d-apis and use --disable-accelerated-2d-canvas with --disable-gpu

Fix Bing Maps not loading in Selenium Chrome: remove --disable-3d-apis, combine --disable-gpu with --disable-accelerated-2d-canvas to stabilize WebDriver.

Opening Bing Maps in a Selenium-driven Chrome session can unexpectedly fail even if the setup worked reliably before. The failure can be triggered by a specific Chrome command-line switch, which blocks the page from loading its graphics layer. Below is a focused walkthrough for diagnosing and fixing this issue without overhauling your automation stack.

Problem in context

The browser was launched with a comprehensive set of flags. After a period of stable operation, the map page started showing an error and refused to load. The following minimal snippet reproduces the scenario.

import os, sys
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service

chrome_cfg = Options()
chrome_cfg.add_argument("start-maximized")
chrome_cfg.add_argument('--use-gl=swiftshader')
chrome_cfg.add_argument('--enable-unsafe-webgpu')
chrome_cfg.add_argument('--enable-unsafe-swiftshader')
chrome_cfg.add_argument("--disable-3d-apis")
chrome_cfg.add_argument('--disable-gpu')
chrome_cfg.add_argument('--no-sandbox')
chrome_cfg.add_argument('--disable-dev-shm-usage')
chrome_cfg.add_argument("start-maximized")
chrome_cfg.add_argument('--log-level=3')
chrome_cfg.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1})
chrome_cfg.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_cfg.add_experimental_option('excludeSwitches', ['enable-logging'])
chrome_cfg.add_experimental_option('useAutomationExtension', False)
chrome_cfg.add_argument('--disable-blink-features=AutomationControlled')

svc = Service()

maps_url = "https://www.bing.com/maps"
browser = webdriver.Chrome(service=svc, options=chrome_cfg)
browser.get(maps_url)
input("Press!")

What is actually going wrong

The switch that blocks the page is --disable-3d-apis. With this flag enabled, the Bing Maps experience fails to initialize. Removing the flag restores normal behavior. This aligns with the observation that the code works again once the switch is not passed to Chrome.

If you still need to keep GPU disabled, it is possible to steer rendering behavior without blocking the entire 3D stack. Adding --disable-accelerated-2d-canvas prevents fallback to software rendering when GPU is disabled, which is useful in combination with --disable-gpu.

Working solution

The fix is to stop passing --disable-3d-apis. Optionally, replace it with --disable-accelerated-2d-canvas. You can also harden the session with additional flags to reduce pop-ups, ads, notifications, and extension noise. If the site shows a consent dialog, an explicit wait-and-click by element id can keep the flow deterministic.

import os, sys
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

chrome_cfg = Options()
chrome_cfg.add_argument("start-maximized")
chrome_cfg.add_argument('--use-gl=swiftshader')
chrome_cfg.add_argument('--enable-unsafe-webgpu')
chrome_cfg.add_argument('--enable-unsafe-swiftshader')
# chrome_cfg.add_argument("--disable-3d-apis")  # removed to allow the page to initialize
chrome_cfg.add_argument("--disable-accelerated-2d-canvas")  # pairs well with --disable-gpu
chrome_cfg.add_argument('--disable-gpu')
chrome_cfg.add_argument('--no-sandbox')
chrome_cfg.add_argument('--disable-dev-shm-usage')
chrome_cfg.add_argument("start-maximized")
chrome_cfg.add_argument('--log-level=3')
chrome_cfg.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1})
chrome_cfg.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_cfg.add_experimental_option('excludeSwitches', ['enable-logging'])
chrome_cfg.add_experimental_option('useAutomationExtension', False)
chrome_cfg.add_argument('--disable-blink-features=AutomationControlled')

# Reduce runtime noise from the UI surface
chrome_cfg.add_argument("--disable-popup-blocking")
chrome_cfg.add_argument("--disable-ads")
chrome_cfg.add_argument("--disable-notifications")
chrome_cfg.add_argument("--disable-extensions")

svc = Service()

maps_url = "https://www.bing.com/maps"
browser = webdriver.Chrome(service=svc, options=chrome_cfg)
browser.get(maps_url)

# Click the consent "Reject" button by its id if it appears

def press_by_id(elem_id="bnp_btn_reject", timeout=10):
    try:
        WebDriverWait(browser, timeout).until(
            EC.element_to_be_clickable((By.ID, elem_id))
        ).click()
    except Exception as exc:
        print(f"Error clicking button: {exc}")

press_by_id()

Why this matters

Automation that tamps down graphics and UI features via broad flags can become brittle against modern web apps. When a single switch like --disable-3d-apis blocks a map from rendering, the whole test or data collection flow stalls. Knowing which switches are safe and which ones short-circuit critical functionality helps avoid intermittent failures and time-consuming triage.

Replacing a blanket 3D shutdown with a more targeted approach keeps the session stable while still respecting constraints such as disabled GPU. It also makes troubleshooting simpler: if the page stops loading, the first suspects are the toggles that directly interfere with rendering.

Takeaways

If Bing Maps fails to load in Selenium, check for --disable-3d-apis and remove it. Use --disable-accelerated-2d-canvas alongside --disable-gpu to prevent fallback to software rendering. Keep the browser surface clean by suppressing pop-ups, ads, notifications, and extensions, and use explicit waits to handle consent prompts by id. Small, deliberate adjustments to launch flags can restore reliability without changing your broader automation design.

The article is based on a question from StackOverflow by Rapid1898 and an answer by Gооd_Mаn.