-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Improve behavior of sending messages with attachments #1877
Improve behavior of sending messages with attachments #1877
Conversation
… uploading attached files
…with-large-attachments
Passing run #1980 ↗︎
Details:
Review all test suite changes for PR #1877 ↗︎ |
…with-large-attachments
Having tested more about the the error message "Image corrupt or truncated", the main reason is because the file is damaged. This issue is what @SebinSong already reported here. I guess it's related to the browser because Google Chrome doesn't raise that issue but Firefox and Safari do. |
Sorry, I can't tell what exactly in Sebin's video shows the same behavior as here. In Sebin's video the images seem to upload with no problem. Also, I don't believe the problem is that the image is corrupted, for a few reasons:
|
@taoeffect, it could seem to be different, but I think it's same in basic. It depends on how much the image is damaged while uploading. Also I can say that not all the images are damaged while uploading. Some are damaged, and some are not. I attached the three screenshots below. Look at the second image which I got in Google Chrome browser. Two images are uploaded in Firefox browser, and they are however opens fine in Google Chrome. That's why I can say it depends on how much the image is damaged. |
@Silver-IT If the images upload fine in Google Chrome, and then display fine in Firefox, it clearly means the images are not damaged. This must be some other problem. Please search online to see what the problem could possibly be. Try asking Claude 3. Or maybe @SebinSong or @corrideat can help? |
@Silver-IT I've written a small function for testing uploads / downloads, and it seems like the
|
If I had to guess, I'd think that it's got to do with the
|
@corrideat, thanks for your kind help. I also think that I also tested keeping the Blob reference until the upload is finished and even more. That Blob (which is used for uploading, and not the one which is created by At the moment, I couldn't guess the which one is making this kinda weird problem. |
It could be an issue that's only visible in Firefox. Besides being different implementations, the code is also different. For example, when uploading Chrome may use a stream and Firefox will not. In reality, using a stream in Chrome requires HTTP 2, so unless you've done something to enable it, the code should be the same (although, if you want to be sure, you can disable the check here: https://github.com/okTurtles/group-income/blob/64e8a2b0892cddc6898b10cf16ce272f8fa86d37/shared/domains/chelonia/files.js#L52C3-L52C41, which will make Chrome and Firefox use the same logic). I don't think that this will help, but you can try. The next thing you can do is upload a file that gets corrupted, download it, and then inspect the original and the downloaded version side-by-side. That could give some information about what's happening. Since the issue happens consistently when showing a file, my guess is that something goes wrong during the upload. |
Maybe somehow the image isn't being drawn or displayed incorrectly? I ask because @corrideat claims that the files are being uploaded and downloaded correctly on Firefox (the same byte sequence is being received...) |
…with-large-attachments
@taoeffect , @Silver-IT
I've just done some research and it seems like instead of using Let me try this in my local dev and share the result of how it goes. |
@taoeffect @Silver-IT async getDateURLOfAttachment (attachment) {
const blob = await sbp('chelonia/fileDownload', attachment.downloadData)
const reader = new FileReader()
return new Promise((resolve) => {
reader.onload = () => { resolve(reader.result) }
reader.readAsDataURL(blob)
})
} This is the before / after of the image I had an issue with, when trying in Firefox Dev Edition. |
Having tested this issue more in different browsers, I can say it works fine in Google Chrome and Brave browser. And in Opera browser, I can not even upload any files, and in other browsers like Firefox and Safari, the file is damaged. Based on my poor understanding of this kind of area, I am not sure but my opinion is that the problem is related to this one.
cc: @taoeffect, @corrideat, @SebinSong |
@Silver-IT: I've managed to find the issue. It was an error in the encryption function, that resulted in sometimes (depending on how the input was chunked) skipping over some data. This has been fixed in ApelegHQ/ts-rfc8188#5 and I've also pushed a new commit that updates the package and addresses this issue. |
Removed dependencies detected. Learn more about Socket for GitHub ↗︎ 🚮 Removed packages: npm/@exact-realty/[email protected] |
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.
Nice work @Silver-IT & @corrideat!
@Silver-IT I tested this to see if #1845 is closed, and with throttling enabled we can see that the issue isn't closed:
file-upload.issue.compressed.mov
For whatever reason, the messages sent after the file upload starts don't get sent immediately. They need to be sent immediately instead of waiting for the file upload to finish or fail.
Also, as a separate unrelated issue (but something to not forget), if we are on a cellular connection (or a slow connection), we don't want to autodownload the files. Instead, a download button overlay should appear over the file, and only if it's clicked should the file preview be downloaded. But we can save that for a separate issue and PR.
@taoeffect, I think the delay is because of that throttle works for all the network transactions. Not only for file uploading. |
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.
Approved!
Great work @Silver-IT, @SebinSong and @corrideat!
It looks like the issue with messages not appearing when they should when throttling is turned on is a bug in Firefox, not in this code, as it works correctly in Brave with throttling enabled.
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.
Great work @Silver-IT !
Summary of Changes