-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.3 Musicbrainz fixes #10875
2.3 Musicbrainz fixes #10875
Conversation
In case of no pNetworkAccessManager change to Failed state.
src/network/webtask.cpp
Outdated
m_state = State::Failed; | ||
onNetworkError( | ||
QNetworkReply::NetworkSessionFailedError, | ||
tr("Request URL issue, network request has not been started"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How could you be sure that this only happens for invalid URLs? Derived classes may return nullptr
for whatever obstacles they encounter during doStartNetworkRequest(). Making such implicit assumptions is incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will change the message accordingly.
break; | ||
case QNetworkReply::TimeoutError: | ||
// Network or server-side timeout | ||
case QNetworkReply::OperationCanceledError: // Client-side timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Client- and server-side abort should be distinguished. Why did you merge them? The state TimedOut
is wrong when manually aborting a request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are here in onNetworkError() this is only called if a start request fails.
The case you mention is handled in slotAbort().
The change was required, because sometime MusicBrainz does not respond at all.
In that case the client Timothy of 60 s takes place. This case is a network error as well, and leads to a proper feedback about this situation to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing code is easier than fruitless arguing and explaining.
Override doNetworkReplyAborted()
in the derived class and do whatever needs to be done.
@@ -123,32 +123,24 @@ void WebTask::onNetworkError( | |||
QNetworkReply::NetworkError errorCode, | |||
const QString& errorString, | |||
const WebResponseWithContent& responseWithContent) { | |||
DEBUG_ASSERT(m_state == State::Pending); | |||
DEBUG_ASSERT(m_state == State::Failed || m_state == State::Pending); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How could the internal state be already Failed when a network reply arrives?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because this function is also called, before the request is issued and the state goes to the pending state.
Line 200 in 41abb4d
onNetworkError( |
Before, the state was artificially set to State::Pending, even though there was already a failure detected.
Probably just to trick the original assertion.
This is fixed now for a traceable usage of states.
src/network/webtask.h
Outdated
@@ -182,6 +182,11 @@ class WebTask : public NetworkTask { | |||
const QString& errorString, | |||
const WebResponseWithContent& responseWithContent); | |||
|
|||
protected: | |||
virtual void doNetworkError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The do
prefix indicates the Template Method pattern with a pure virtual function that is only invoked by the base class and inaccessible for derived classes. Derived classes are supposed to implement those functions, but are not allowed to invoke them at arbitrary times.
In contrast this seems to be an ordinary, overridable virtual function. It is also unclear even clear why and when you should override it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is you suggestion to improve this situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O have renamed onNetworkError() to doNetworkError()
Sure, there might be undiscovered bugs. But I cannot follow most of these changes, especially in the base classes, and some decisions appear to be inconsistent as I outlined. |
Others may take over. Time to say goodbye, finally. |
Btw, my aoide web tasks worked flawlessly until now. With this PR they are triggering unexpected errors when aborted. |
Please share some details, that we have at least a chance to fix this. |
Example: Abort a pending search and start a new search. There is nothing to fix, because it works as expected. I already pointed out that it is wrong to remove the distinction between client-side abort and server-side timeout and evidence proves me right. Please fix your downstream code instead of subverting upstream code. |
I cannot confirm that abborting a request and starting a new one is broken now. Instead this PR fixes the stalled GUI in case of a client timout. Did you actually tried this code or do you share an assumption from the code review. Let's discuss along the code what is the real issue. Or are you prepared to overrule this PR with your one, like the previous one? |
I tried it after expressing my concerns on this PR and and the results proved me right. |
I have battle tested this stuff probably more than anyone else. If there are issues than point them out and provide instructions to reproduce them. |
I reported a bug earlier #10796. The bug is, if one of the MusicBrainz URL has an empty XML, whole task was failing even though there are other releases found. |
I do not love the design of these classes and I agree that there is some weirdness with the "on" and "do" functions and various overrides, but I don't think daniel's changes are harmful to the design of the code.
@uklotzde if you want us to fix this new issue then you need to provide instructions to reproduce, and/or logs so that we can track it down. It is not fair to say that a PR is broken but you're unwilling to say exactly how. Daniel said he tried to reproduce your issue based on your description and was unable to do so. We have one user who has said this PR explicitly fixes a bug, and that bug has steps to reproduce. On that basis alone I am inclined to approve this PR so that we fix a known bug. I think the main problem here is the complete lack of testing on this code. Writing tests for network code is tedious and difficult, and often requires mocks or even artificial environments to properly test, but I think we would all be well served by taking some time to establish tests for this code that covers the cases mentioned. Then at least we can talk about regressions in terms of concrete results or writing new tests. I would propose that for this PR we write a single test that exercises the specific bug being fixed here. Yes, that may require a bunch of effort to establish a foundation. Then, after this is merged, if Uwe can write a test for client side cancellation that fails or is flaky, we can fix that in a subsequent PR. |
Now the tests are in place. This was a lot of work! |
11a486b
to
b66b76a
Compare
b66b76a
to
10326bc
Compare
@fatihemreyildiz can you reconfirm that this branch fixes your issue? If so, ok to merge |
Hey @ywwg, I have tested again and this PR fixes issue #10796 👍 . Here is a screenshot I just took: However while I was testing it, I guess I discovered an issue. I don't know if it is only happening to me. When I tried to import metadata, sometimes the Tag Fetcher Dialog was populating with This is happened when I looked for metadata populated from track property and abort the task, after aborting I changed the songs via The steps to reproduce is:
|
I was able to reproduce and fix the stray() "Operation canceled" signal when using the next/previous buttons. |
Hey @daschuer , I've tried it a lot. Couldn't receive the Also, when I fetch metadata from track properties and close only the DlgTagFetcher and press |
Thank you for testing. No need for a new bug. I will add the fix here. |
@fatihemreyildiz Done. |
I have tested it couple of times, and It seems like the bug is resolved 👍 |
Cool, thank you for the immediate help! @ywwg this is ready for merge now. Please have a look. |
This includes a couple of fixes regarding non fatal errors and missing GUI feedback after client timeout.
This also improves the error message that is shown in some cases.
Fixes #10883