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

When uploading multiple files, the client does not preserve order #27884

Closed
interruptinuse opened this issue May 6, 2024 · 14 comments
Closed

Comments

@interruptinuse
Copy link

Steps to reproduce

  1. Select multiple files (e.g., mp3 files) in a file browser: a.mp3, b.mp3, c.mp3.
  2. Drag and drop into a chat window.

Expected behaviour

Files are uploaded and displayed in selection order: a, b, c.

This behavior used to be the (undocumented?) status quo until recently, which I personally found useful.

Actual behaviour

Files are now uploaded in parallel. This is not an issue by itself, and actually noticeably improves upload speeds. During the upload, the order of files looks preserved on the uploading client (until relaunching the client), regardless of when each individual file upload actually finished. However, the order of uploads is not guaranteed anymore, and files may arrive shuffled depending on file size, e.g.: a, c, b.

This change was introduced in a very recent version of Telegram Desktop, most likely in 0dcc439.

Operating system

Arch Linux, x86_64, Plasma 6

Version of Telegram Desktop

4.16.8

Installation source

Other (unofficial) source

Crash ID

No response

Logs

No response

@Aokromes
Copy link
Collaborator

Aokromes commented May 6, 2024

it's os "issue" if you select 3 files and drag a file a will be upload 1st, if you select c file c will be upload fist.

@interruptinuse
Copy link
Author

interruptinuse commented May 7, 2024

This is not an OS issue. It's the fact that file uploads are delivered from the server at the time the file is done uploading (not when it's started uploading), and this order used to be deterministic. Now that multiple files are uploaded at the same time, this is no longer guaranteed.

@Aokromes
Copy link
Collaborator

Aokromes commented May 7, 2024

#26971 (comment)

@interruptinuse
Copy link
Author

I'm not using Windows.

@Aokromes
Copy link
Collaborator

Aokromes commented May 7, 2024

I'm not using Windows.

still it's the same "bug"

@john-preston john-preston reopened this May 9, 2024
@john-preston
Copy link
Member

Need to test. I was hoping I did preserve the order.

@interruptinuse
Copy link
Author

interruptinuse commented May 10, 2024

I've been trying to repro this, and so far it's been extremely finicky. I've only triggered the reordering issue with ungrouped MP3 uploads in a channel so far; it seems to work much better after a pause in traffic (subsequent attempts to reproduce are fruitless).

I actually haven't assembled a large enough sample size to confidently say that parallel uploads are to blame, but I don't think I remember it happening before.

Here's what it looks like:

1. In the file manager (Dolphin)

Screenshot_20240510_144411

2. In the Arch Linux 4.16.8 client after uploading (correct order)

Screenshot_20240510_145041

3. In mobile and web clients (wrong order)

photo_2024-05-10_14-54-44

Screenshot_20240510_144525

So it does seem to me that it's an upload heisenbug.

@interruptinuse
Copy link
Author

Another repro with white noise MP3s.

Generator script
#!/usr/bin/env bash
set -ex
for i in {01..20} ; do
  COVER_SIZE=500
  head -c "$((3*COVER_SIZE*COVER_SIZE))" /dev/urandom \
    | convert -depth 8 -size "${COVER_SIZE}x${COVER_SIZE}" RGB:- $i.jpg

  DURATION=$(( 100 + ( RANDOM % 100 ) )).$(( RANDOM % 100 ))
  ffmpeg -f lavfi -i "anoisesrc=a=0.1:c=white:d=$DURATION" -i $i.jpg \
    -map 0:0 -map 1:0 -id3v2_version 3 \
    -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" \
    -metadata artist="White Noise" -metadata title="$i" -b:a 192k -c:v copy -y $i.mp3
  rm -v $i.jpg
done
Arch client, after uploading

Screenshot_20240510_150816

iOS client

photo_2024-05-10_15-09-52

@UpscaleAnon
Copy link

I think it depends on size of file, because I've had this happen a lot in the past with other files. I think it's because telegram processes the files a bit before they get sent in a channel and if the second file is finished processing (not uploading) before the first one, it'll get "sent" first, no matter what you do. It is extremely annoying. Telegram seems more prone to this after the recent update that boosted upload speed (Thank fuck for that update, finally usable speeds).

@john-preston
Copy link
Member

I couldn't reproduce that.

@interruptinuse Can you please:

  1. launch the app
  2. enable debug logs by typing "debugmode" in Settings (like a cheat-code in a game)
  3. reproduce the bug (upload the files and see them with a wrong order in a mobile app)
  4. make screenshots of uploaded files and mobile app files order
  5. in Settings type "viewlogs" (like a cheat-code in a game) to see where the logs are stored
  6. close the app completely (using Ctrl+Q keyboard shortcut)
  7. .zip DebugLogs folder and send it to me at https://t.me/preston (this logs will contain all the network activity from the moment you've enabled them and till quit)

I'll see the send file requests order at least.

@john-preston
Copy link
Member

I hope I've found the problem. I'm building a test version now..

@john-preston
Copy link
Member

I hope this will be fixed in 5.0.2 later today.

@interruptinuse
Copy link
Author

@john-preston Could not reproduce the issue with build_5_0_1_1.tar.xz so far. I did have a few MSG_WAIT_FAILED responses in MTP logs, but no reordering issues.

@interruptinuse
Copy link
Author

Closing as fixed in 84ec2a5 (5.0.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants