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

HQ version isn't downloaded for some images #2207

Closed
touzainanboku opened this issue Sep 30, 2016 · 38 comments
Closed

HQ version isn't downloaded for some images #2207

touzainanboku opened this issue Sep 30, 2016 · 38 comments
Labels
Bug This is an issue with Slide. This is where something in the app isn't working as intended. Needs Reproduction This issue needs to be reproduced by another person.

Comments

@touzainanboku
Copy link
Contributor

touzainanboku commented Sep 30, 2016

Slide version: 5.5-alpha2-dirty
Android version: 6.0.1

I've experienced this issue where for some images, tapping HQ does indeed load the HQ version, but downloading it doesn't save the high res version. I am using "Low Quality through Reddit (lower resolution)" for image data saving.

Example 1

If you open this on desktop, you'll see that it's a gigantic 16.4 MB image with a resolution of 1920 x 10762. Slide does indeed load this version when HQ is tapped, but when I download the image, what's saved is 337 KB and has a resolution of 240x1345.

Example 2

Like the one above, what you get on desktop is a 4608 x 3233 image and a size of 2.1 MB, which is what Slide loads when HQ is tapped, but what gets downloaded is a 1152 x 809, 0.93 MB image.

I also tried both with data saving completely disabled. Both images showed the correct high res versions by default, but the smaller images were downloaded regardless.

I can look for more examples if that helps.

EDIT: I've played around with a few more images, and in some cases the opposite happens. What gets downloaded is larger in size and higher in resolution than what gets loaded when HQ is tapped. While I'm personally not bothered by that one, I think it'd be better if both tapping HQ and download the image consistently downloaded the highest resolution possible.

@Nxt3 Nxt3 added Bug This is an issue with Slide. This is where something in the app isn't working as intended. Needs Reproduction This issue needs to be reproduced by another person. labels Oct 2, 2016
@ccrama
Copy link
Collaborator

ccrama commented Oct 3, 2016

That is not actually how it works, it downloads the content url when you're in data saving mode and downloads the currently displayed image if you are not in data saving mode, and never the low quality version. I don't really know why it appears to be doing that behavior, but I don't really think it's possible for Slide to be doing that. I have personally never seen this happen

@touzainanboku
Copy link
Contributor Author

touzainanboku commented Oct 3, 2016

downloads the currently displayed image if you are not in data saving mode

That seems to be what's happening pretty much all the time, but it seems like occasionally a lower quality version is saved. Not the LQ version that gets displayed in the app, but something in-between.

Just in case you haven't, could you try opening the links I posted above and saving them? If what gets saved is similar to what I got, then it's reproducible, and if it's a bug, it can be fixed. If, however, the correct HQ version is saved on your end, perhaps it depends on specific settings, in which case I'll try more testing.

@ccrama
Copy link
Collaborator

ccrama commented Oct 3, 2016

It is loading correctly for me on and off wifi. I think the issue might actually lie with your gallery app, Google Photos shows a pixelated version of the image regardless of where it's downloaded from (Slide or Chrome), and the image you linked to actually doesn't obey the data saving settings for Imgur (it's not on Imgur), so the issue cannot lie with data saving settings and is most likely not Slide related

@touzainanboku
Copy link
Contributor Author

touzainanboku commented Oct 4, 2016

loading correctly

Just to check, you mean downloading or loading in-app? Because in-app the app loads the highest quality available just fine. It's the downloading that I'm experiencing issues with.

the issue might actually lie with your gallery app

I'm using QuickPic and checking the detail for each image to check the size. If there's any other app that you consider more reliable, please tell me and I will check with those.

the issue cannot lie with data saving settings

This is probably true, since it happens to me regardless of what data saving settings I have.

is most likely not Slide related

I genuinely dislike saying this because I find constantly comparing with rival apps disrespectful, but this is for the purpose of testing, so I tried opening the first link in Sync, and then downloading it, and the correct gigantic version (roughly 16 MB) was saved. I didn't try other apps cause it takes too long to load that image, and I'm about to leave for class. I can try it later if you want.

As for the second link, Boost, Sync, Relay, and Opengur all download a 4608 x 3233 image.

I can look for more links that have this behavior, if you think that helps with debugging.

@ccrama
Copy link
Collaborator

ccrama commented Oct 4, 2016

Yes, I'm referring to downloading. Downloading the images both on and off data saving mode are identical to the ones downloaded in chrome by opening the image externally for the links you provided in the OP (the 16mb one). I'm really not able to reproduce that behavior, and the code also makes it impossible to be downloading the lq image (the link displayed is not the same as the one downloaded, if the image is lq then it will display a reduced size image but keeps the original link in tact), as it creates a new activity with the link provided in the submission, and downloads that file separately from the media view.

The fact that it can't be reproduced on my devices under the same circumstances leads me to believe it is not something relating to Slide (also, I've never had another report of this). Is there anything that would be interfering with this on your device?

@touzainanboku
Copy link
Contributor Author

touzainanboku commented Oct 4, 2016

I see. That's certainly strange. I'm assuming the saved file for the second link is also the 4608 x 3233 one on your end, right?

I can't think of anything that could be interfering with this, but I'll try and test different settings, and on different devices. Thanks for the help.

EDIT1: just tried downloading that image again. 16 MB of data was used, the amount of time it took to download matches the images size, but what's saved is 337 KB. Checked with QuickPic and Solid Explorer. That's really weird.

EDIT2: BTW, while that image isn't hosted on Imgur, I get an HQ button when I open that image with either data saving mode (Reddit or Imgur). And the one displayed by default is definitely not the HQ version (I can tell because the top and bottom are cropped). Is that a bug?

EDIT3: changed data saving mode to Imgur, cleared Slide's cache, closed Slide from recents, opened that thread, and tapped download. Once again roughly 16 MB of data was used, the time it took matches the 16 MB size and my connection speed, but the saved file is 337 KB with a resolution of 240 x 1345.

EDIT4: based on what I described above, it seems like the issue isn't happening when downloading, but when actually saving what's downloaded. What do you think?

EDIT6: Tried on my Xperia Z1. It's less modified than my daily, with the only changes being a lowered DPI and KCAL. Same result as above. I updated Slide to 5.5-alpha2-dirty, cleared its data, and went straight to that post without logging in or changing any settings. It seems to download roughly 16 MB, but what's saved is the 337 KB one. I'll try to test it on a completely stock device later.

@ccrama
Copy link
Collaborator

ccrama commented Oct 4, 2016

Are you 100% sure your gallery app is displaying the image correctly? It saves the bytes downloaded directly and doesn't compress or mess with it at all (straight to file). Also it will show the HQ button if there is a displayed lq Reddit hosted image, and it will load the actual content URL when you click it.

It could also just be the file has the incorrect size stated in the metadata, but the actual file itself is 16 mb (an issue with the image uploaded, not with how Slide downloaded it).

@touzainanboku
Copy link
Contributor Author

touzainanboku commented Oct 4, 2016

Are you 100% sure your gallery app is displaying the image correctly?

I highly doubt it's incorrect, but it's certainly a possibility, which is why I checked in Solid Explorer, which also said it's a 337 KB file. I understand that you wouldn't want to waste time trying to debug something only to find out that it was caused by a different app showing the file size incorrectly, so if there's any other app you want me to check with, please tell me. I can even upload the downloaded file somewhere if that helps.

Also it will show the HQ button if there is a displayed lq Reddit hosted image, and it will load the actual content URL when you click it.

Oops, I'd forgotten how data saving functioned. My bad.

It could also just be the file has the incorrect size stated in the metadata, but the actual file itself is 16 mb (an issue with the image uploaded, not with how Slide downloaded it).

That would probably cause the image downloaded from other apps to have the same issue, but they don't seem to.

EDIT: as promised, I tested on a stock Z5 (6.0.1). I installed Slide, found the post, and downloaded the image. I didn't change any settings. Same result.

@touzainanboku
Copy link
Contributor Author

touzainanboku commented Oct 11, 2016

So I tried something different. I cleared Slide's cache, swiped it away from recents, opened the second link and downloaded it. Then I went to /sdcard/emulated/0/Android/data/me.ccrama.redditslide/cache, and since I'd only opened a single post after clearing Slide's cache, there were only 3 files, one of which was just called "journal". Of the other two, one was the LQ version that got displayed when I opened the post, but the other one was the correct file: 2.1 MB (2.06 on my phone, but it's just different counting methods), with a resolution of 4608 x 3233. Still, what actually gets saved in my chosen directory is 1152 x 809 and 1.34 MB.

So whatever's happening, it's definitely after it finishes downloading.

@ccrama
Copy link
Collaborator

ccrama commented Oct 14, 2016

It turns out it was scaling based on your device density, and yours was probably low and scaling it proportionally. Should be fixed now

@ccrama ccrama closed this as completed Oct 14, 2016
@touzainanboku
Copy link
Contributor Author

Sweet. Thanks.

@touzainanboku
Copy link
Contributor Author

touzainanboku commented Oct 15, 2016

Got the update. The app now behaves differently, but there are still some issues.

  • For the first link, the image is the correct resolution, the right amount of detail, but has an incorrect size. The one downloaded on desktop was 16.4 MB, while the one Slide downloaded is 16.6. That small difference is not a big deal, but it's probably a symptom of something else.
  • For the second link, the image is the correct resolution, but isn't as detailed as what's downloaded on desktop, and by that I mean it looks like an upscaled image. Also, the size is 16.6 MB, while on desktop it was 2.1 MB.

Density being the cause makes sense to an extent, since my Z2 and Z1 are running on 400 instead of the stock 480, but the Note and the Z5 were running stock DPI. The Z5 was completely stock in every way.

@ccrama
Copy link
Collaborator

ccrama commented Oct 18, 2016

It could very well be the conversion from a jpg to a png that is giving you these results. Nothing in the code is scaling the images at all

@touzainanboku
Copy link
Contributor Author

I'm not sure I follow. What part of the software on my phone would be responsible for that if not Slide?

@ccrama
Copy link
Collaborator

ccrama commented Oct 18, 2016

JPG format is different than PNG, PNG is more compact than a JPG file, which is converted when saving through Slide (all images are saved as PNG regardless of what they began as). The file is not the same as the one on Imgur, it is a differently compressed one

@touzainanboku
Copy link
Contributor Author

So Slide converts to PNG regardless of the original format? May I ask why?

@ccrama
Copy link
Collaborator

ccrama commented Oct 18, 2016

It is more compact and I have to choose either PNG or JPG. JPG is better for flat gradients like images, while PNG is better for text which I assumed to be the majority of Reddit images to be saved. Slide downloads the image into memory into a bitmap, and I then convert that bitmap into a PNG file. Other major apps (and Imgur apps) do this as well. Definitely explains the difference in file size, though!

@touzainanboku
Copy link
Contributor Author

So there's no way to make the app save whatever the original file is?

Assuming what you're saying is true, that would mean all images saved by a single app will either be .jpg or .PNG right?

@ccrama
Copy link
Collaborator

ccrama commented Oct 18, 2016

The code was based off of Opengur, so yes that is what it does. And no, sorry. There is really no downside to it though, photos are usually saved in PNG format anyway which has more efficient compression

@touzainanboku
Copy link
Contributor Author

Without naming anything, I see some other apps which save both pngs and jpegs, so I find it hard to believe that it's completely impossible.

There is really no downside to it though

Compared to an implementation where everything is saved as-is, I'd say saving a 2 MB image as a 16 MB file is a downside. Especially for people with limited internal storage.

@ccrama
Copy link
Collaborator

ccrama commented Oct 18, 2016

I didn't say it is impossible, but I personally don't think it's worth rewriting the system to support both file types. JPG images are lossier than PNG, and you are getting a better/original quality image with PNG (recompressing JPG images is not good, that's how you get JPG artifacts)

@touzainanboku
Copy link
Contributor Author

touzainanboku commented Oct 18, 2016

I personally don't think it's worth rewriting the system to support both file types

I wouldn't really disagree with you if it was just file size, but for me it's currently affecting image quality as well on some links. It's just not as pleasant when I have to use other apps to download images when I want to be sure I get what I wanted.

you are getting a better quality image with PNG

PNG seems to be smaller only when an image is mostly the exact same color (like a non-compressed screenshot from an app), so if the original is .jpeg and therefore already compressed, I doubt converting to PNG would lead to much other than a larger file.

And as I said, for me the file downloaded from the second link is lower quality than the original while being a lot larger in size. I can upload what Slide downloaded on my device if you want to check.

I also checked Opengur's files, and while you're right in that it saves everything as a .jpeg, it doesn't seem to actually be converting anything. I downloaded a png from Opengur and while the filename does indeed say .jpeg, according to QuickPic the MIMEtype is still PNG. And on desktop Photoshop refuses to open the file saying:

Could not complete your request because an unknown or invalid JPEG marker type is found.

It works fine after renaming to .PNG. On the other hand, it looks like Slide doesn't just change the extension in the name, but also converts the file. QuickPic shows MIMEtype for all Slide downloads as PNG, even for ones that I'm certain are from .jpeg links. Also, my first example link was already a PNG, so considering the difference in file size between Slide and desktop, that means Slide converts both PNGs and jpegs to PNG.

Anyway, thanks for taking the time to respond. I really appreciate it :)

@ccrama
Copy link
Collaborator

ccrama commented Oct 18, 2016

It was actually pretty easy to tell it to copy the cached file from UIL, so it should be the original file from the server instead of a recompressed image. This should fix any discrepancy between file type and size, and the final release will name the file the same as it was on the Imgur server. Thank you for the in-depth analysis! And that is interesting that Opengur names it but does not recompress it, they should probably do what I'm doing as well :)

@touzainanboku
Copy link
Contributor Author

Sweet! Looking forward to the next update. Thanks again.

@touzainanboku
Copy link
Contributor Author

touzainanboku commented Oct 18, 2016

Got the alpha-4 update. I tried a few links (including my second example link) after updating and clearing cache, and they're all getting saved as PNGs, and the sizes don't match either. Or did I misunderstand your previous comment?

@ccrama
Copy link
Collaborator

ccrama commented Oct 18, 2016

That isn't really possible, are you sure you updated?

@touzainanboku
Copy link
Contributor Author

App info (from the Settings app) says 5.5-alpha4. Same in Slide's about section. Maybe I need to do a reinstall?

@ccrama
Copy link
Collaborator

ccrama commented Oct 18, 2016

Actually the file name may be incorrect but the contents are correct

@touzainanboku
Copy link
Contributor Author

The second image was still 16.69 MB, and QuickPic shows MIMEtype as PNG. It might get fixed with a reinstall, so I'll try that later.

@ccrama
Copy link
Collaborator

ccrama commented Oct 18, 2016

Are you sure the image you were downloading is not a PNG? This is pulling the file directly from Imgur and copying it to your storage, there is really not much room to go wrong. A reinstall probably won't do anything (reinstalls only really could fix issues with cache or files in storage, not the code of the app)

@touzainanboku
Copy link
Contributor Author

It's this link.

@ccrama
Copy link
Collaborator

ccrama commented Oct 18, 2016

If it pulled the image from Reddit, it's saving the Reddit PNG image instead of the Imgur one. Other than that, I really don't know man :/

@touzainanboku
Copy link
Contributor Author

Time for more testing :)

  • Uninstalled Slide
  • Reinstalled it (from the Play Store)
  • Gave it storage permission
  • Opened this post (I opened the link from here on GitHub)
  • Tapped download
  • Set download folder
  • Tapped download again
  • Image got downloaded
  • Opened it through the notification to ensure I'm not confusing it with some other picture

And it was 16.69 MB with the file extension and MIMEtype both being PNG.

Next, I tried the following:

  • Opened Slide normally
  • Logged in (didn't sync subreddit colors)
  • When to /r/slideforreddit and opened alpha-4's thread
  • Created a comment with the following content (didn't post it):

[test](http://i.imgur.com/wIJtitj.jpg)

  • Tapped Preview
  • Opened the link from the comment preview
  • Tapped download
  • Opened the image through the notification

Same as above, 16.69 MB, with file extension and MIMEtype both showing PNG in QuickPic. Since you said it might be saving the Reddit PNG, I figured this test might be useful since a comment preview (that's not posted) is on the device, not on Reddit.

Then to be sure I:

  • Cleared Slide's cache
  • Swiped it away from recents
  • When to /r/slideforreddit and opened alpha-4's thread
  • Created a comment with the following content (didn't post it):

[test](http://i.imgur.com/wIJtitj.jpg)

  • Tapped Preview
  • Opened the link from the comment preview
  • Tapped download
  • Opened the image through the notification

Same result.

Take this more as an FYI. I don't want you to stress yourself over this.

@touzainanboku
Copy link
Contributor Author

BTW, could we keep this open for now? It doesn't seem widespread so I know it doesn't deserve a high priority, but it'd be great if it could be fixed at some point.

@ccrama
Copy link
Collaborator

ccrama commented Oct 20, 2016

Is the file name a large random string? If so, it's the Reddit image and this is the intended behavior and the image from Imgur cannot be compared to the image from Reddit, because they are different

@ccrama
Copy link
Collaborator

ccrama commented Oct 20, 2016

I made a few more changes which will hopefully fix the issue you're seeing

@touzainanboku
Copy link
Contributor Author

touzainanboku commented Oct 20, 2016

Is the file name a large random string?

Looks like it, but is there any other case? All images saved by Slide seem to have random names.

If so, it's the Reddit image and this is the intended behavior and the image from Imgur cannot be compared to the image from Reddit, because they are different

Not sure what this means. Does this mean what gets downloaded isn't from Imgur? Wouldn't the test I did (loading it from a comment preview) circumvent Reddit entirely?

I made a few more changes which will hopefully fix the issue you're seeing

Thank you. Fingers crossed!

@touzainanboku
Copy link
Contributor Author

touzainanboku commented Oct 22, 2016

Just installed 5.5 (from APKMirror, that is).

Second example link is now working! Correct file size, resolution, file extension, and MIMEtype. Same for the first link. Sweet!

There are a few little things:

- This link doesn't have a file extension in the URL. The file is actually a jpeg (you can check on desktop), and what Slide saves has the correct file size, resolution, and MIMEtype, but the file extension is PNG. Very minor.

- i.reddituploads links like this one get saved without a file extension, so you can't see them in your gallery. The saved file is the correct thing though, it's just the file extension.

EDIT: This should probably be a separate issue.

And thanks so much for all the work you did on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is an issue with Slide. This is where something in the app isn't working as intended. Needs Reproduction This issue needs to be reproduced by another person.
Projects
None yet
Development

No branches or pull requests

3 participants