diff --git a/pythonlib/camoufox/utils.py b/pythonlib/camoufox/utils.py index 3c1d1c1..1cdbd77 100644 --- a/pythonlib/camoufox/utils.py +++ b/pythonlib/camoufox/utils.py @@ -456,10 +456,6 @@ def launch_options( # Convert executable path to a Path object executable_path = Path(abspath(executable_path)) - # Block WebGL by default until a fix is avaliable. - if block_webgl is None: - block_webgl = True - # Handle virtual display if virtual_display: env['DISPLAY'] = virtual_display @@ -472,6 +468,10 @@ def launch_options( if os: check_valid_os(os) + # webgl_config requires OS to be set + elif webgl_config: + raise ValueError('OS must be set when using webgl_config') + # Add the default addons add_default_addons(addons, exclude_addons) @@ -565,19 +565,15 @@ def launch_options( firefox_user_prefs['media.peerconnection.enabled'] = False # Allow allow_webgl parameter for backwards compatibility - if block_webgl and not launch_options.pop('allow_webgl', False): + if block_webgl or launch_options.pop('allow_webgl', True) is False: firefox_user_prefs['webgl.disabled'] = True + LeakWarning.warn('block_webgl') else: - # Warn the user about WebGL - if not i_know_what_im_doing: - print( - 'NOTICE: WebGL is known to cause crashing or behave unexpectedly.' - 'A fix will be avaliable soon.' - ) - # If the user has provided a specific WebGL vendor/renderer pair, use it if webgl_config: merge_into(config, sample_webgl(target_os, *webgl_config)) + else: + merge_into(config, sample_webgl(target_os)) # Use software rendering to be less unique merge_into( diff --git a/pythonlib/camoufox/warnings.yml b/pythonlib/camoufox/warnings.yml index 10a87db..a8f360b 100644 --- a/pythonlib/camoufox/warnings.yml +++ b/pythonlib/camoufox/warnings.yml @@ -35,4 +35,7 @@ ff_version: >- no_region: >- Because you did not pass in a locale region, Camoufox will generate one for you. - This can cause suspicion if your IP does not match your locale region. \ No newline at end of file + This can cause suspicion if your IP does not match your locale region. + +block_webgl: >- + Disabling WebGL is not recommended. Many WAFs will check if WebGL is enabled. \ No newline at end of file diff --git a/pythonlib/camoufox/webgl/sample.py b/pythonlib/camoufox/webgl/sample.py index 8318a20..ddb6d18 100644 --- a/pythonlib/camoufox/webgl/sample.py +++ b/pythonlib/camoufox/webgl/sample.py @@ -44,21 +44,23 @@ def sample_webgl( (vendor, renderer), ) result = cursor.fetchone() - conn.close() if not result: raise ValueError(f'No WebGL data found for vendor "{vendor}" and renderer "{renderer}"') if result[3] <= 0: # Check OS-specific probability + # Get a list of possible (vendor, renderer) pairs for this OS + cursor.execute( + f'SELECT DISTINCT vendor, renderer FROM webgl_fingerprints WHERE {os} > 0' + ) + possible_pairs = cursor.fetchall() raise ValueError( - f'Vendor "{vendor}" and renderer "{renderer}" combination not valid for {os.title()}.' + f'Vendor "{vendor}" and renderer "{renderer}" combination not valid for {os.title()}.\n' + f'Possible pairs: {", ".join(str(pair) for pair in possible_pairs)}' ) - return { - 'vendor': result[0], - 'renderer': result[1], - **orjson.loads(result[2]), - } + conn.close() + return orjson.loads(result[2]) # Get all vendor/renderer pairs and their probabilities for this OS cursor.execute(f'SELECT vendor, renderer, data, {os} FROM webgl_fingerprints WHERE {os} > 0') diff --git a/pythonlib/camoufox/webgl/webgl_data.db b/pythonlib/camoufox/webgl/webgl_data.db index e0b06d6..c28820e 100644 Binary files a/pythonlib/camoufox/webgl/webgl_data.db and b/pythonlib/camoufox/webgl/webgl_data.db differ diff --git a/pythonlib/pyproject.toml b/pythonlib/pyproject.toml index 1296e0c..72a7459 100644 --- a/pythonlib/pyproject.toml +++ b/pythonlib/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "camoufox" -version = "0.4.3" +version = "0.4.4-beta" description = "Wrapper around Playwright to help launch Camoufox" authors = ["daijro "] license = "MIT"