Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

MagMueller
Copy link
Collaborator

@MagMueller MagMueller commented Aug 30, 2025

Auto-generated PR for: highlight in parallel


Summary by cubic

Render element highlights in parallel and add timing to key paths to speed up screenshot annotation. This makes highlighting faster on pages with many elements.

  • Refactors
    • Converted create_highlighted_screenshot to async and processed elements with asyncio.gather via a new process_element_highlight coroutine.
    • Updated create_highlighted_screenshot_async to await the async path; improved log to include highlight duration.
    • Added time_execution_async to create_highlighted_screenshot(_async), get_or_create_cdp_session, DOM build without highlights, and clean screenshot capture.

@MagMueller MagMueller merged commit e1ab411 into main Aug 30, 2025
12 checks passed
@MagMueller MagMueller deleted the highlight-in-parallel branch August 30, 2025 05:18
Copy link

github-actions bot commented Aug 30, 2025

Agent Task Evaluation Results: 0/3 (0%)

View detailed results
Task Result Reason
amazon_laptop ❌ Fail Task failed with error: Event handler 139880199543296.139880191637952(?▶ BrowserStartEvent#5daa ✅) returned an error -> No module named 'utils'
browser_use_pip ❌ Fail Task failed with error: Event handler 140484384690624.140484385257920(?▶ BrowserStartEvent#f009 ✅) returned an error -> No module named 'utils'
captcha_cloudflare ❌ Fail Task failed with error: Event handler 140497535491952.140497535417088(?▶ BrowserStartEvent#57a2 ✅) returned an error -> No module named 'utils'

Check the evaluate-tasks job for detailed task execution logs.


# Execute all element processing tasks in parallel
if tasks:
await asyncio.gather(*tasks, return_exceptions=True)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Async Highlighting Fails Due to ImageDraw Thread Safety

The create_highlighted_screenshot function attempts parallel highlighting with asyncio.gather, but process_element_highlight is synchronous, adding overhead without performance gain. Multiple tasks concurrently modify the shared PIL ImageDraw object, which is not thread-safe and can corrupt the screenshot's highlights.

Fix in Cursor Fix in Web

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

import time
from typing import TYPE_CHECKING

from utils import time_execution_async
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect import path causes runtime ImportError; utils is not a top-level module in this package. Use the package-qualified import instead.

(Based on your team's feedback about matching the project's tab-based indentation style, the one-line fix follows your formatting conventions.)

Prompt for AI agents
Address the following comment on browser_use/browser/watchdogs/dom_watchdog.py at line 7:

<comment>Incorrect import path causes runtime ImportError; utils is not a top-level module in this package. Use the package-qualified import instead.

(Based on your team&#39;s feedback about matching the project&#39;s tab-based indentation style, the one-line fix follows your formatting conventions.)</comment>

<file context>
@@ -4,6 +4,8 @@
 import time
 from typing import TYPE_CHECKING
 
+from utils import time_execution_async
+
 from browser_use.browser.events import (
</file context>
Suggested change
from utils import time_execution_async
from browser_use.utils import time_execution_async

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant