Open Bug 1919275 Opened 2 months ago Updated 2 months ago

"browsingContext.setViewport" hangs when executed in parallel to a navigation

Categories

(Remote Protocol :: WebDriver BiDi, defect, P2)

defect
Points:
3

Tracking

(Not tracked)

People

(Reporter: whimboo, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [webdriver:backlog])

When trying to write a test for bug 1918287 I noticed that browsingContext.setViewport hangs when a navigation command runs in parallel:

@pytest.mark.asyncio
@pytest.mark.parametrize("type_hint", ["tab", "window"])
async def test_when_context_created(
    bidi_session, inline, new_tab, wait_for_event, wait_for_future_safe, type_hint
):
    test_viewport = {"width": 499, "height": 599}

    await bidi_session.browsing_context.navigate(
        context=new_tab["context"], url=inline("<div>Foo"), wait="complete"
    )

    await bidi_session.session.subscribe(
        events=["browsingContext.navigationStarted"]
    )
    on_navigation_started = wait_for_event("browsingContext.navigationStarted")

    # Save the task to await for it later.
    task = asyncio.create_task(
        bidi_session.browsing_context.navigate(
            context=new_tab["context"], url=inline("<div>Bar"), wait="complete"
        )
    )

    await on_navigation_started
    await bidi_session.browsing_context.set_viewport(
        context=new_tab["context"], viewport=test_viewport
    )

    assert await get_viewport_dimensions(bidi_session, new_tab) == test_viewport

Here the command never returns from the call to _awaitViewportDimensions:

0:16.64 pid:64720 1726576973462	RemoteAgent	DEBUG	WebDriverBiDiConnection c5ced0ee-71c4-4582-af7d-f641afaaa970 -> {"id":5,"method":"browsingContext.setViewport","params":{"context":"93fc42f9-d888-4096-94e3-b1ea8a992826","viewport":{"width":499,"height":599}}}
 0:16.64 pid:64720 1726576973462	RemoteAgent	TRACE	Received command browsingContext.setViewport for destination ROOT
 0:16.64 pid:64720 1726576973464	RemoteAgent	TRACE	Received command browsingContext._awaitViewportDimensions for destination WINDOW_GLOBAL
 0:16.64 pid:64720 1726576973467	RemoteAgent	TRACE	MessageHandler WINDOW_GLOBAL for session 060bfea4-dbbf-4b8c-8ee5-e4f6b3b1c18b is being destroyed
 0:16.64 pid:64720 1726576973467	RemoteAgent	TRACE	Unregistered MessageHandler WINDOW_GLOBAL for session 060bfea4-dbbf-4b8c-8ee5-e4f6b3b1c18b
 0:16.64 pid:64720 1726576973468	RemoteAgent	TRACE	Received command browsingContext._applySessionData for destination WINDOW_GLOBAL
 0:16.64 pid:64720 1726576973468	RemoteAgent	TRACE	Created MessageHandler WINDOW_GLOBAL for session 060bfea4-dbbf-4b8c-8ee5-e4f6b3b1c18b
 0:16.64 pid:64720 1726576973468	RemoteAgent	TRACE	[13] NavigationListenerChild Loading state: flags: 131088, status: 2152398850,  isStart: false, isStop: true, isNetwork: false, isBindingAborted: true, targetURI: https://web-platform.test:8443/webdriver/tests/support/inline.py?doc=%3C%21doctype+html%3E%0A%3Cmeta+charset%3DUTF-8%3E%0A%3Cdiv%3EBar&mime=text%2Fhtml&charset=UTF-8
 0:16.64 pid:64720 1726576973469	RemoteAgent	TRACE	[14] NavigationListenerChild Loading state: flags: 983041, status: 0,  isStart: true, isStop: false, isNetwork: true, isBindingAborted: false, targetURI: https://web-platform.test:8443/webdriver/tests/support/inline.py?doc=%3C%21doctype+html%3E%0A%3Cmeta+charset%3DUTF-8%3E%0A%3Cdiv%3EBar&mime=text%2Fhtml&charset=UTF-8
 0:16.64 pid:64720 1726576973469	RemoteAgent	TRACE	[93fc42f9-d888-4096-94e3-b1ea8a992826] Skipping already tracked navigation, navigationId: 2f261ea3-459c-40d1-a370-175e6309cb70
 0:16.65 pid:64720 1726576973470	RemoteAgent	TRACE	Received command browsingContext._applySessionData for destination WINDOW_GLOBAL
 0:16.65 pid:64720 1726576973470	RemoteAgent	TRACE	Created MessageHandler WINDOW_GLOBAL for session 060bfea4-dbbf-4b8c-8ee5-e4f6b3b1c18b
 0:16.65 pid:64720 1726576973470	RemoteAgent	TRACE	MessageHandler WINDOW_GLOBAL for session 060bfea4-dbbf-4b8c-8ee5-e4f6b3b1c18b is being destroyed
 0:16.65 pid:64720 1726576973470	RemoteAgent	TRACE	Unregistered MessageHandler WINDOW_GLOBAL for session 060bfea4-dbbf-4b8c-8ee5-e4f6b3b1c18b
 0:16.65 pid:64720 1726576973470	RemoteAgent	TRACE	[14] NavigationListenerChild Loading state: flags: 196612, status: 0,  isStart: false, isStop: false, isNetwork: false, isBindingAborted: false, targetURI: https://web-platform.test:8443/webdriver/tests/support/inline.py?doc=%3C%21doctype+html%3E%0A%3Cmeta+charset%3DUTF-8%3E%0A%3Cdiv%3EBar&mime=text%2Fhtml&charset=UTF-8
 0:16.65 pid:64720 1726576973471	RemoteAgent	TRACE	[14] NavigationListenerChild Loading state: flags: 131088, status: 0,  isStart: false, isStop: true, isNetwork: false, isBindingAborted: false, targetURI: https://web-platform.test:8443/webdriver/tests/support/inline.py?doc=%3C%21doctype+html%3E%0A%3Cmeta+charset%3DUTF-8%3E%0A%3Cdiv%3EBar&mime=text%2Fhtml&charset=UTF-8
 0:16.65 pid:64720 1726576973476	RemoteAgent	TRACE	[93fc42f9-d888-4096-94e3-b1ea8a992826] Navigation finished for url: https://web-platform.test:8443/webdriver/tests/support/inline.py?doc=%3C%21doctype+html%3E%0A%3Cmeta+charset%3DUTF-8%3E%0A%3Cdiv%3EBar&mime=text%2Fhtml&charset=UTF-8 (2f261ea3-459c-40d1-a370-175e6309cb70)
 0:16.65 pid:64720 1726576973476	RemoteAgent	TRACE	[14] ProgressListener Loading state: isStart=false isStop=true status=0x0, loadType=0x200001
 0:16.65 pid:64720 1726576973476	RemoteAgent	TRACE	[14] ProgressListener Stop: has error=false url=https://web-platform.test:8443/webdriver/tests/support/inline.py?doc=%3C%21doctype+html%3E%0A%3Cmeta+charset%3DUTF-8%3E%0A%3Cdiv%3EBar&mime=text%2Fhtml&charset=UTF-8
 0:16.65 pid:64720 1726576973476	RemoteAgent	DEBUG	WebDriverBiDiConnection c5ced0ee-71c4-4582-af7d-f641afaaa970 <- {"type":"success","id":4,"result":{"navigation":"2f261ea3-459c-40d1-a370-175e6309cb70","url":"https://web-platform.test:8443/webdriver/tests/support/inline.py?doc=%3C%21doctype+html%3E%0A%3Cmeta+charset%3DUTF-8%3E%0A%3Cdiv%3EBar&mime=text%2Fhtml&charset=UTF-8"}}
 0:44.09 TEST_END: TIMEOUT, expected OK
Points: --- → 3
Priority: -- → P2
Whiteboard: [webdriver:backlog]

The severity field is not set for this bug.
:whimboo, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(hskupin)
Severity: -- → S3
Flags: needinfo?(hskupin)
You need to log in before you can comment on or make changes to this bug.