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

8.0.92 make app size bigger #25750

Open
albilaga opened this issue Nov 5, 2024 · 7 comments · May be fixed by #25686
Open

8.0.92 make app size bigger #25750

albilaga opened this issue Nov 5, 2024 · 7 comments · May be fixed by #25686
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/android 🤖
Milestone

Comments

@albilaga
Copy link

albilaga commented Nov 5, 2024

Description

We are updating our app from 8.0.82 to 8.0.92 and have increased file size to 40MB for the .apk. This is really unexpected because that is too much jump. 5MB might be quite reasonable but we didn't expect it to increase 40MB. After we check what is inside that increased and compared the size we found the issue is our res folder is much bigger. Is there any changes from how resizetizer work? Image The right is from 8.0.92 and the left one is from 8.0.82.
We then tried also to reproduce with another MAUI sample app and found with smaller app we found increase app size on 5MB. With big app like us, then it is hit us with 40MB app size increase on Android

iOS app also increased around 10MB and after we check the inside it is caused because of the resources size in our folder increased as well

Steps to Reproduce

  1. Clone https://github.com/albilaga/MAUI-store-app
  2. Build with release dotnet build -c Release
  3. Copy the apk from bin folder
  4. Clean obj and bin folder
  5. Checkout branch maui8.0.82
  6. Build with release dotnet build -c Release
  7. Compare apk size from those 2. 8.0.82 will come around ~53.9MB but apk built with 8.0.92 will come around ~58.6MB. The image resources in here is very little compared to what we have
    Image

Link to public reproduction project repository

https://github.com/albilaga/MAUI-store-app

Version with bug

8.0.92 SR9.2

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.82 SR8.2

Affected platforms

iOS, Android

Affected platform versions

Android 11 and up. iOS 15 and up

Did you find any workaround?

No response

Relevant log output

No response

@bronteq
Copy link

bronteq commented Nov 5, 2024

In Maui 8.0.90 was merged this about Resizetizer #23924

@albilaga
Copy link
Author

albilaga commented Nov 5, 2024

Ah I miss that. So now it become more high quality which is contributing to our app size. Which is not mentioned in release notes. Thank you @bronteq . So for now for us we can just accept the increasing file size right?

@thisisthekap
Copy link
Contributor

I understand that the fix done in #23924 is important. But to my point of view, this should be configurable while keeping SKFilterQuality.High as default value. I am currently working on a PR for making that configurable.

@thisisthekap thisisthekap linked a pull request Nov 5, 2024 that will close this issue
@rmarinho rmarinho transferred this issue from dotnet/maui Nov 8, 2024
@rmarinho rmarinho transferred this issue from dotnet/android Nov 8, 2024
Copy link

We've found some similar issues:

  • #25683 , similarity score: 100%

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

@rmarinho rmarinho added the area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer label Nov 8, 2024
@rmarinho rmarinho added this to the .NET 9 SR1.1 milestone Nov 8, 2024
@rmarinho rmarinho added p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/android 🤖 potential-regression This issue described a possible regression on a currently supported version., verification pending and removed potential-regression This issue described a possible regression on a currently supported version., verification pending labels Nov 8, 2024
@thisisthekap
Copy link
Contributor

#25686 fixes this, because it enables us to set None as value for FilterQuality, which brings back the old behavior.

@mattleibow
Copy link
Member

mattleibow commented Nov 18, 2024

I had a look at this and the PR may help, but I think the cause for the underlying issue is more something that you probably should avoid.

Currently, you are including a 800x800 image and then asking that to be included with the rest of the image processing - including the upscaling. The base size of 400x400 is for the lowest supported density (mdpi) and this means that it is being upscaled for all the densities (hdpi, xhdpi, xxhdpi and xxxhdpi)

For non-vector images (such as jpg or png) you should not be resizing but instead be marking it as "copy only" by setting an attribute on the element: Resize="false":

<MauiImage Include="Resources\Images\electronics.png" BaseSize="400,400" Resize="false" />

read more here: https://learn.microsoft.com/dotnet/maui/user-interface/images/images#resize-an-image

Sometimes you do have a large png that you will be downscaling with a very small base size - for app icons or tab icons. This is typically the most common case and so it is the default to resize.

In your case, you have 4 very large images that get upscaled to 1600x1600 and about 1.3MB and with the higher res it is about 2.8MB. If you mark as a copy, they are the original size of about 1MB.

The total apk size is reduced from 52MB to 41MB. A saving of 11MB.

I will review the PR independently of this issue as I think the PR may add value, however lower quality images after upscaling is probably the worse of letting the device hardware upscale if it needs to.

@espenrl
Copy link
Contributor

espenrl commented Nov 18, 2024

@mattleibow The resizetizer does a great job. Perhaps it could output a warning when developers use too big dimensions for the source image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/android 🤖
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

6 participants