async def launch_firefox_async( pw_instance: "AsyncPlaywrightContextManager", h3: bool, endpoint: Endpoint, warmup: bool, qlog: bool, pcap: bool, expnt_id: int, run_id: int, ) -> json: # set up firefox preference firefox_prefs = {} firefox_prefs["privacy.reduceTimerPrecision"] = False if h3: if qlog: firefox_prefs[ "network.http.http3.enable_qlog"] = True # enable qlog firefox_prefs[ "network.http.http3.enabled"] = True # enable h3 protocol firefox_prefs[ "network.http.spdy.enabled.http2"] = False # disable h2 protocol firefox_prefs[ "network.http.spdy.enabled"] = False # disable h1.1 protocol # the openlightspeed server works with a different h3 version than the rest of the servers port = endpoint.get_port() h3_version = "29" if endpoint.get_endpoint() == "server-openlitespeed": h3_version = "27" firefox_prefs[ "network.http.http3.alt-svc-mapping-for-testing"] = f"{endpoint.port};h3-{h3_version}=:{port}" # attempt to launch browser try: if pcap: pcap_file = f"{os.getcwd()}/results/packets/async-{expnt_id}/firefox/{run_id}-{h3}.keys" return await pw_instance.firefox.launch( headless=True, firefox_user_prefs=firefox_prefs, env={"SSLKEYLOGFILE": pcap_file}) else: return await pw_instance.firefox.launch( headless=True, firefox_user_prefs=firefox_prefs, ) except Exception as e: # if browser fails to launch, stop this request and write to the database logger.exception(str(e)) return None