REOPENED 242248
[WPE][GTK] 'Stop' button does not STOP
https://bugs.webkit.org/show_bug.cgi?id=242248
Summary [WPE][GTK] 'Stop' button does not STOP
dave
Reported 2022-07-01 08:30:02 PDT Comment hidden (spam)
Attachments
dave
Comment 1 2022-07-01 08:36:55 PDT Comment hidden (spam)
Michael Catanzaro
Comment 2 2022-07-01 08:44:34 PDT
I believe webkit_web_view_stop_loading() has been broken for several years, perhaps even more.
dave
Comment 3 2022-07-01 09:15:52 PDT Comment hidden (spam)
Michael Catanzaro
Comment 4 2022-07-01 11:13:45 PDT Comment hidden (obsolete)
dave
Comment 5 2022-07-01 11:49:30 PDT Comment hidden (spam)
Michael Catanzaro
Comment 6 2024-06-03 19:37:09 PDT
I found two example websites in bug #274727 that continue loading forever, which seemed like a good way to test this bug. On both websites (discourse.gnome.org and www.vox.com), the problem is the same. We get so far as DocumentLoader::stopLoading, and there are three possible ways the load can be canceled. In this case, the main resource is not loading -- it's only a subresource that is still loading -- so we take the second path and call DocumentLoader::setMainDocumentError instead of DocumentLoader::cancelMainResourceLoad. This gets reported back to WebKit layer in WebLocalFrameLoaderClient::setMainDocumentError, which ignores it. I suspect that Stop has not worked properly since WebKitLegacy (at least).
Michael Catanzaro
Comment 7 2024-06-05 10:33:02 PDT
I was on completely the wrong track. I was looking at WebLocalFrameLoaderClient::dispatchDidFailLoading, but that is used to indicate a particular resource has failed to load. I should have been looking at WebLocalFrameLoaderClient::dispatchDidFailLoad, which indicates the entire page failed to load. That's supposed to be called by FrameLoader::checkLoadCompleteForThisFrame, but isn't happening. There are a variety of reasons why it could fail.
Michael Catanzaro
Comment 8 2024-06-05 10:57:39 PDT
Plot twist: the load actually finishes successfully (at least in the case I'm debugging) and WebKitWebView actually emits the LOAD_FINISHED event, so there's nothing to stop. But the PageLoadStateObserver does not fire the didChangeIsLoading event, so WebKitWebView thinks it is still loading event though the last event was LOAD_FINISHED. So that's why stop doesn't work. It's not actually loading.
Michael Catanzaro
Comment 9 2024-06-05 11:45:14 PDT
PageLoadState::isLoading returns true if !data.pendingAPIRequest.url.isNull() even if the page load state is finished. It was added in 150676@main to force isLoading to return true immediately after starting a load but before the UI process receives the notification that the load has started. That actually makes sense to me, though. The load in question has already started and finished, so surely there shouldn't still be a pending API request URL.
Michael Catanzaro
Comment 10 2024-06-05 12:20:45 PDT
*** This bug has been marked as a duplicate of bug 274727 ***
Michael Catanzaro
Comment 11 2024-06-05 14:15:43 PDT
Reopening because bug #275178 reveals an actual problem with Stop. When there is a delayed load event, Stop doesn't work until the delayed load event finishes. Surely that shouldn't happen; nothing should ever be able to block Stop.
Michael Catanzaro
Comment 12 2024-06-05 15:31:34 PDT
I naively attempted this: diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp index 61c2a2e235a0..cff229c32dfa 100644 --- a/Source/WebCore/loader/FrameLoader.cpp +++ b/Source/WebCore/loader/FrameLoader.cpp @@ -2714,11 +2714,6 @@ void FrameLoader::checkLoadCompleteForThisFrame(LoadWillContinueInAnotherProcess { ASSERT(m_client->hasWebView()); - // FIXME: Should this check be done in checkLoadComplete instead of here? - // FIXME: Why does this one check need to be repeated here, and not the many others from checkCompleted? - if (m_frame->document()->isDelayingLoadEvent()) - return; - switch (m_state) { case FrameState::Provisional: { // FIXME: Prohibiting any provisional load failures from being sent to clients @@ -2732,6 +2727,11 @@ void FrameLoader::checkLoadCompleteForThisFrame(LoadWillContinueInAnotherProcess if (!provisionalDocumentLoader) return; + // FIXME: Should this check be done in checkLoadComplete instead of here? + // FIXME: Why does this one check need to be repeated here, and not the many others from checkCompleted? + if (m_frame->document()->isDelayingLoadEvent() && !m_provisionalDocumentLoader->isStopping()) + return; + // If we've received any errors we may be stuck in the provisional state and actually complete. auto& error = provisionalDocumentLoader->mainDocumentError(); if (error.isNull()) @@ -2790,6 +2790,11 @@ void FrameLoader::checkLoadCompleteForThisFrame(LoadWillContinueInAnotherProcess if (m_documentLoader->isLoadingInAPISense() && !m_documentLoader->isStopping() && !m_checkingLoadCompleteForDetachment) return; + // FIXME: Should this check be done in checkLoadComplete instead of here? + // FIXME: Why does this one check need to be repeated here, and not the many others from checkCompleted? + if (m_frame->document()->isDelayingLoadEvent() && !m_documentLoader->isStopping()) + return; + setState(FrameState::Complete); // FIXME: Is this subsequent work important if we already navigated away? Unfortunately, removing the isDelayingLoadEvent check from the top of FrameLoader::checkLoadCompleteForThisFrame causes the RELEASE_ASSERT(presentationSize) in VideoFrameGStreamer::createWrappedSample to fail. Not sure why.
Michael Catanzaro
Comment 13 2024-06-06 03:27:22 PDT
(In reply to Michael Catanzaro from comment #12) > Unfortunately, removing the isDelayingLoadEvent check from the top of > FrameLoader::checkLoadCompleteForThisFrame causes the > RELEASE_ASSERT(presentationSize) in VideoFrameGStreamer::createWrappedSample > to fail. Not sure why. OK, it's actually a coincidence. I tested many times with the patch not applied and never saw the crash, and then saw the crash several times with the patch applied, and then removed the patch and didn't see it again a few times. But today it still happens with the patch removed.
Michael Catanzaro
Comment 14 2024-06-06 03:36:15 PDT
Well I don't known what changed (perhaps something on the server?), but I'm seeing this crash almost every time now rather than the problem with Stop not working. So we'll just have to deal with the crash first. Reported as bug #275205
Note You need to log in before you can comment on or make changes to this bug.