Closed proninyaroslav closed 7 years ago
I will need some help to test this, I will release another version with debug symbols, but if you can reproduce the crash in an arm 32 bits, I already have the debug symbols for it.
Hi @proninyaroslav, 1.2.0.13-RC12
is out, do you mind send me a crash report with the new version?
We are already having a great number of this error in our reports CC @gubatron
Hi. I could not catch crash, but the problem with incorrect priorities remains.
@proninyaroslav the crash is fixed in 1.2.0.13-RC14
, but the issue of the inconsistency, still didn't have time to look at it
So fix is already ready and I can test it?
no, still not ready
hi @proninyaroslav can you tell me if this error is happening with the methods from SessionManager
, or a custom one outside jlibtorrent
? btw, 1.2.0.14
is out
I already tested. Suppose I have 2 files in the torrent. One file has a size of 5 MB, and the second file has a size of 1 MB. I select the second file, start downloading. In the end, both files are downloaded, although the priorities returned by TorrentHandle.filePriorities ()
are correct (ignore for first and normal for second file). TorrentStatus.getTotalWanted ()
returns 6 MB, although it should return 1 MB. You can check it on this torrent magnet:?xt=urn:btih:AD838261E23F84886E1219EDF53A8B608A8D5820&dn=Microsoft+Windows+10+v1703+AIO+8+in+1+Aprile+2017.torrent
. Try downloading only .txt file.
I just tested, and it downloads only the smaller file. Are you sure you are using one of our methods? and not a custom one?
Hmm, that seems strange. I use only SessionManager
and TorrentHandle
methods. I think I'll have to make a more detailed log.
yes please, provide as much info as you can
I think that the problem is in TorrentHandle.prioritizeFiles()
, since the priorities after calling this method don't change.
that call is an "async" one, if you query the vector immediately after setting it, you will see no change
I get priorities every STATS alert (for test).
Priorities don't change for magnet's TorrentHandle
, which received metadata and was launched for download. I'll try to find an error in my code, maybe I'm using this method incorrectly.
if you find the same behavior in the SessionManager#download
s, report back please
Yes, it only happens with magnets. I noticed that using the TorrentHandle
after getting metadata (without recreating) is a bad idea, since it contains a lot of errors, including this error #174.
A small offtopic, sorry.
I have a question about using SessionManager.fetchMagnet
: let's say I have a SessionManager
as a singleton. I need an indefinite time to wait for the fetching of magnet. Is it possible to implement asynchronousSessionManager.fetchMagnet
in a separate thread for multiple magnets at the same time?
at this moment, you could wrap fetchMagnet
in your own thread to simulate the async task, and that's fine because I made it thread safe, but I doubt that would scale well. The fundamental problem is that I assumed that "fetching a magnet" is an expensive job inside libtorrent
, and in some sense it is. Also, we actually don't want (or need) such a big scale for our own use; it is not fast in nature either, since query the DHT is not that trivial.
I do think fetchMagnet
warrants some rethinking in order to address this and other limitations. Ideas are welcome, and all of them can be tested outside SessionManager
or changing the source code, since swig()
give you the full low level API.
Thanks for clarifying. Yes, until this point I've used a low level API to bypass the limitations of fetchMagnet
, but alas, these two problems don't allow me to use the low level API at the moment.
these two problems don't allow me to use the low level API at the moment.
Which ones?
I see, I though they are more related to the java high level API than the low level one
Hi. I checked some torrents and magnets and TorrentHandle.prioritizeFiles
doesn't always work correctly. After changing the priority, I still get the old priorities from the TorrentHandle.filePriorities()
method and the ignored files continue to be downloaded. I created a small test sample for this. As you can see after adding a torrent, I try to change the priority of the first file, but the priority does not change in 2 minutes, although the torrent was downloaded in a minute.
Waiting for nodes in DHT (10 seconds)...
DHT contains 95 nodes
Fetching the magnet uri, please wait...
Torrent added
Expected priorities:
priority=IGNORE file=Play Claw 3.exe
priority=FOUR file=FFF.NFO
priority=FOUR file=FILE_ID.DIZ
priority=FOUR file=PlayClaw.3.0.build.2048_KEYGEN-FFF.exe
priority=FOUR file=установка.txt
[20:30:45] Current priorities:
priority=FOUR file=Play Claw 3.exe
priority=FOUR file=FFF.NFO
priority=FOUR file=FILE_ID.DIZ
priority=FOUR file=PlayClaw.3.0.build.2048_KEYGEN-FFF.exe
priority=FOUR file=установка.txt
...
[20:31:09] Current priorities:
priority=FOUR file=Play Claw 3.exe
priority=FOUR file=FFF.NFO
priority=FOUR file=FILE_ID.DIZ
priority=FOUR file=PlayClaw.3.0.build.2048_KEYGEN-FFF.exe
priority=FOUR file=установка.txt
Torrent finished
[20:31:10] Current priorities:
priority=FOUR file=Play Claw 3.exe
priority=FOUR file=FFF.NFO
priority=FOUR file=FILE_ID.DIZ
priority=FOUR file=PlayClaw.3.0.build.2048_KEYGEN-FFF.exe
priority=FOUR file=установка.txt
...
[20:32:06] Current priorities:
priority=FOUR file=Play Claw 3.exe
priority=FOUR file=FFF.NFO
priority=FOUR file=FILE_ID.DIZ
priority=FOUR file=PlayClaw.3.0.build.2048_KEYGEN-FFF.exe
priority=FOUR file=установка.txt
Code:
private static final String MAGNET = "magnet:?xt=urn:btih:bff641545f7ba0d5cdd1517d068885f7612aad5b&dn=rutor.info&tr=udp://opentor.org:2710&tr=udp://opentor.org:2710&tr=http://retracker.local/announce";
SessionManager s = new SessionManager();
CountDownLatch signal = new CountDownLatch(1);
s.addListener(new AlertListener() {
@Override
public int[] types()
{
return null;
}
@Override
public void alert(Alert<?> alert)
{
switch (alert.type()) {
case ADD_TORRENT:
System.out.println("Torrent added");
TorrentHandle th = ((AddTorrentAlert) alert).handle();
th.resume();
TorrentInfo ti = th.torrentFile();
Priority[] p = th.filePriorities();
p[0] = Priority.IGNORE;
System.out.println("Expected priorities:");
for (int i = 0; i < ti.numFiles(); i++)
System.out.println(String.format("priority=%-8sfile=%s",
p[i],
ti.files().fileName(i)));
System.out.println();
th.prioritizeFiles(p);
break;
case STATS:
th = ((StatsAlert) alert).handle();
ti = th.torrentFile();
p = th.filePriorities();
System.out.println(String.format("[%s] Current priorities:",
new Time(System.currentTimeMillis())));
for (int i = 0; i < ti.numFiles(); i++)
System.out.println(String.format("priority=%-8sfile=%s",
p[i],
ti.files().fileName(i)));
System.out.println();
break;
case TORRENT_FINISHED:
System.out.println("Torrent finished\n");
break;
}
}
});
s.start();
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run()
{
long nodes = s.stats().dhtNodes();
if (nodes >= 10) {
System.out.println("DHT contains " + nodes + " nodes");
signal.countDown();
timer.cancel();
}
}
}, 0, 1000);
System.out.println("Waiting for nodes in DHT (10 seconds)...");
boolean r = signal.await(10, TimeUnit.SECONDS);
if (!r) {
System.out.println("DHT bootstrap timeout");
System.exit(0);
}
System.out.println("Fetching the magnet uri, please wait...");
byte[] data = s.fetchMagnet(MAGNET, 30, true);
if (data == null) {
System.out.println("data == null");
s.stop();
return;
}
File f = File.createTempFile("test", "torrent");
FileOutputStream fos = new FileOutputStream(f);
fos.write(data);
s.download(new TorrentInfo(f), new File(System.getProperty("user.dir")));
System.in.read();
s.stop();
Hi @proninyaroslav, I found a bug I introduced a few commits ago, it should be fixed now with https://github.com/frostwire/frostwire-jlibtorrent/commit/cdc037c3c24d4cf3995f468473941acd1d48bdc1. I will release an RC
version to test soon.
1.2.0.15-RC1
is out, but don't use it, something is off with the LTO optimization
@proninyaroslav 1.2.0.15-RC2
is out, give it a try and let us know
Thanks, I will test as soon as it appears in maven.
it's already
It works:
Expected priorities:
priority=IGNORE file=Play Claw 3.exe
priority=FOUR file=FFF.NFO
priority=FOUR file=FILE_ID.DIZ
priority=FOUR file=PlayClaw.3.0.build.2048_KEYGEN-FFF.exe
priority=FOUR file=установка.txt
[17:43:54] Current priorities:
priority=IGNORE file=Play Claw 3.exe
priority=FOUR file=FFF.NFO
priority=FOUR file=FILE_ID.DIZ
priority=FOUR file=PlayClaw.3.0.build.2048_KEYGEN-FFF.exe
priority=FOUR file=установка.txt
Closing this?
Hi. I got this cyclic crash after reproducing this problem https://github.com/proninyaroslav/libretorrent/issues/111 . The problem is that
jlibtorrent
incorrectly handling the list of ignored files and downloads them.TorrentHanle.filePriorities()
returns the correct file priorities, but they do not coincide with reality, because ignored files are being downloaded.