Skip to content
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

Merged
merged 23 commits into from
Nov 3, 2022
Merged

2.3 Musicbrainz fixes #10875

merged 23 commits into from
Nov 3, 2022

Conversation

daschuer
Copy link
Member

@daschuer daschuer commented Sep 7, 2022

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

@daschuer daschuer added the bug label Sep 7, 2022
@daschuer daschuer added this to the 2.3.4 milestone Sep 7, 2022
m_state = State::Failed;
onNetworkError(
QNetworkReply::NetworkSessionFailedError,
tr("Request URL issue, network request has not been started"),
Copy link
Contributor

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.

Copy link
Member Author

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
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

#10884

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);
Copy link
Contributor

@uklotzde uklotzde Sep 7, 2022

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?

Copy link
Member Author

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.

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.

@@ -182,6 +182,11 @@ class WebTask : public NetworkTask {
const QString& errorString,
const WebResponseWithContent& responseWithContent);

protected:
virtual void doNetworkError(
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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()

@uklotzde
Copy link
Contributor

uklotzde commented Sep 7, 2022

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.

@uklotzde
Copy link
Contributor

uklotzde commented Sep 7, 2022

Others may take over. Time to say goodbye, finally.

@uklotzde
Copy link
Contributor

uklotzde commented Sep 8, 2022

Btw, my aoide web tasks worked flawlessly until now. With this PR they are triggering unexpected errors when aborted.

@daschuer
Copy link
Member Author

daschuer commented Sep 8, 2022

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.

@uklotzde
Copy link
Contributor

uklotzde commented Sep 8, 2022

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.

@daschuer
Copy link
Member Author

daschuer commented Sep 8, 2022

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?

@uklotzde
Copy link
Contributor

uklotzde commented Sep 8, 2022

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.

@uklotzde
Copy link
Contributor

uklotzde commented Sep 8, 2022

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.

@fatihemreyildiz
Copy link
Contributor

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 have tested it and now it is resolved. The result is:
Result

@daschuer
Copy link
Member Author

daschuer commented Sep 9, 2022

@uklotzde

I tried it after expressing my concerns on this PR and and the results proved me right.

Can you please explain step by step how to reproduce the issue? Maybe you have seen the bug recently fixed here:
#10878

@ywwg
Copy link
Member

ywwg commented Oct 1, 2022

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.

Btw, my aoide web tasks worked flawlessly until now. With this PR they are triggering unexpected errors when aborted.

@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.

@daschuer
Copy link
Member Author

Now the tests are in place. This was a lot of work!
@ywwg Can we merge this now?

@daschuer daschuer force-pushed the musicbrainz_fixes branch 2 times, most recently from 11a486b to b66b76a Compare October 21, 2022 19:19
@ywwg
Copy link
Member

ywwg commented Oct 24, 2022

@fatihemreyildiz can you reconfirm that this branch fixes your issue? If so, ok to merge

@fatihemreyildiz
Copy link
Contributor

Hey @ywwg, I have tested again and this PR fixes issue #10796 👍 . Here is a screenshot I just took:
FixedIssue

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 Operation Canceled error.

This is happened when I looked for metadata populated from track property and abort the task, after aborting I changed the songs via Next & Previous buttons on track properties, and pressed on Import Metadata button again. Could you please try it too?

The steps to reproduce is:

  • Populate Properties of a song
  • Press Import Metadata From Musicbrainz
  • Close the Tag Fetcher Dialog (After fetching is success or while fetching, that doesn't matter)
  • Change the songs via buttons on Properties
  • The task is starting without the menu after each track change.

@daschuer
Copy link
Member Author

I was able to reproduce and fix the stray() "Operation canceled" signal when using the next/previous buttons.
@fatihemreyildiz can you confirm that?

@fatihemreyildiz
Copy link
Contributor

Hey @daschuer , I've tried it a lot. Couldn't receive the Operation Canceled error. As far as I tested, it is fixed.

Also, when I fetch metadata from track properties and close only the DlgTagFetcher and press Next/Prev buttons the task is starting on the background. I can observe it on the console.
Edit: I've also tried it on various 2.3 branches and I can still observe this issue. On upstream/main there is no such an issue. I think this is a bug needs to be reported. What do you think?

@daschuer
Copy link
Member Author

Thank you for testing. No need for a new bug. I will add the fix here.

@daschuer
Copy link
Member Author

@fatihemreyildiz Done.
Please test again. I have also fixed an issue that happens because the track is received twice after next. One Time form DlgTagFetcher and again from DlgTrackInfo
Thank you.

@fatihemreyildiz
Copy link
Contributor

I have tested it couple of times, and It seems like the bug is resolved 👍
Thanks.

@daschuer
Copy link
Member Author

daschuer commented Nov 1, 2022

Cool, thank you for the immediate help!

@ywwg this is ready for merge now. Please have a look.

@ywwg ywwg merged commit 76fbfb2 into mixxxdj:2.3 Nov 3, 2022
@daschuer daschuer deleted the musicbrainz_fixes branch November 16, 2022 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants