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

Background pause #13245

Closed
xtemp09 opened this issue Aug 9, 2020 · 4 comments
Closed

Background pause #13245

xtemp09 opened this issue Aug 9, 2020 · 4 comments
Labels
GUI GUI-related issues/changes

Comments

@xtemp09
Copy link

xtemp09 commented Aug 9, 2020

In response to: #13237.
Thanks for your response, however, I ought to disagree with you in the sentence "qBittorrent/libtorrent obviously use multi-threading already."

When a user presses the pause button, the QAction causes the following function:

void TransferListWidget::pauseSelectedTorrents()
{
    for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
        torrent->pause();
}

But, Bittorrent does not use multithreading in this case. The freeze can be caused by many things, since the pause function produces some actions.

The function should look like this:

void TransferListWidget::pauseSelectedTorrents()
{
    for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) {
        torrent->pause();
	QCoreApplication::processEvents();
	}
}

Perhaps, multithreading is unnecessary in this case, but background pause would be good:

void TransferListWidget::pauseSelectedTorrents()
{
    for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
	QTimer::singleShot(200, Qt::CoarseTimer, [torrent](){torrent->pause();});
}

Of course, the use of QThread::create(Function &&f) is better, but it requires more than one line of code.

I would post it to the case I opened, but comments were closed.

@jagannatharjun
Copy link
Member

jagannatharjun commented Aug 9, 2020

this may not be the real cause, the real part is already non-blocking https://github.com/arvidn/libtorrent/blob/3ced76ecf12d9bfe4ce53b77e53a1f7484331560/src/torrent_handle.cpp#L281

@FranciscoPombal
Copy link
Member

@xtemp09

Thanks for the detailed post. This is more of the kind of helpful, thought out post I expected from the get-go. I'm glad we're on the same page now.

As mentioned, the current way libtorrent pauses torrents is already non-blocking, qBittorrent just uses that under the hood.

Any chance you can post some profiling info/debugging information to narrow down the real culprit of the blockage?

@FranciscoPombal FranciscoPombal added GUI GUI-related issues/changes Waiting info Waiting for participants to supply more info/fulfill template requirements labels Aug 9, 2020
@xtemp09
Copy link
Author

xtemp09 commented Aug 10, 2020

I looked at the logs, qBt does not seem to write any additional info.

I can’t imagine a way how I can provide profiling info without installing MSVS, compiling libtorrent, boost, openSSL, zlib etc.

I see here only two options:

  • The developers should provide a debug version with additional verbosity. This version has to be published every time when developing in alpha/beta phase. This will simplify beta testing and bug reporting.
  • Another way is to add debug mode or verbosity option.

I think, the first option is a great idea.

@xtemp09 xtemp09 closed this as completed Aug 10, 2020
@FranciscoPombal
Copy link
Member

@xtemp09

I can’t imagine a way how I can provide profiling info without installing MSVS, compiling libtorrent, boost, openSSL, zlib etc.

I suspect application-level logging wouldn't help much in this case, this is the kind of problem that is better solved (or at all) with a profiler, debugger, and such tools. If you're not willing to help solve your own problem, no one else is going to do it for you.

Installing the developer tools on Windows can be a pain, but you can just grab a Windows 10 dev VM, which is ready to go: https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/. Compiling qBittorrent from source on Windows is pretty tiresome if you follow the wiki procedure, but it is significantly easier if you use vcpkg and the improved CMake scripts (#12746):

  1. Clone that PR.
  2. Clone vcpkg
  3. Bootstrap vcpkg
  4. Install the following packages with vcpkg:
    boost-circular-buffer:x64-windows-static
    libtorrent:x64-windows-static
    qt5-base:x64-windows-static
    qt5-svg:x64-windows-static
    qt5-tools:x64-windows-static
    qt5-winextras:x64-windows-static
    
  5. Build qBittorrent with (adjust the --config argument to your liking, if using a single-config generator instead, like Ninja, you should use -DCMAKE_BUILD_TYPE=RelWithDebInfo at configure-time to select the build type instead):
    cmake -B build -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE=path\to\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
    cmake --build build --config RelWithDebInfo
    
  6. Run and debug with Visual Studio

This version has to be published every time when developing in alpha/beta phase. This will simplify beta testing and bug reporting.

The first attempt at such a thing is here: #13070, but it's taking a while to merge. In the meantime, occasionally other users other users provide builds of recent commits (for example: #2904 (comment)).

@qbittorrent qbittorrent locked and limited conversation to collaborators Feb 27, 2021
@xavier2k6 xavier2k6 removed the Waiting info Waiting for participants to supply more info/fulfill template requirements label Feb 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
GUI GUI-related issues/changes
Projects
None yet
Development

No branches or pull requests

4 participants