Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Refactor computed styles in enhanced_snapshot.py to include only essential styles used in the codebase, reducing potential crashes on heavy sites. Update service.py to reflect the change, noting that only 9 styles are now actively used for snapshot requests.
Magnus Müller629a4d6ed18c
diff --git a/browser_use/dom/enhanced_snapshot.py b/browser_use/dom/enhanced_snapshot.pyindex 09ebca734..6c08c637a 100644--- a/browser_use/dom/enhanced_snapshot.py+++ b/browser_use/dom/enhanced_snapshot.py@@ -16,32 +16,16 @@ from browser_use.dom.views import DOMRect, EnhancedSnapshotNode# Only the ESSENTIAL computed styles for interactivity and visibility detectionREQUIRED_COMPUTED_STYLES = [- # Essential for visibility- 'display',- 'visibility',- 'opacity',- 'position',- 'z-index',- 'pointer-events',- 'cursor',- 'overflow',- 'overflow-x',- 'overflow-y',- 'width',- 'height',- 'top',- 'left',- 'right',- 'bottom',- 'transform',- 'clip',- 'clip-path',- 'user-select',- 'background-color',- 'color',- 'border',- 'margin',- 'padding',+ # Only styles actually accessed in the codebase (prevents Chrome crashes on heavy sites)+ 'display', # Used in service.py visibility detection+ 'visibility', # Used in service.py visibility detection+ 'opacity', # Used in service.py visibility detection+ 'overflow', # Used in views.py scrollability detection+ 'overflow-x', # Used in views.py scrollability detection+ 'overflow-y', # Used in views.py scrollability detection+ 'cursor', # Used in enhanced_snapshot.py cursor extraction+ 'pointer-events', # Used for clickability logic+ 'position', # Used for visibility logic]