Redth / ResizetizerNT

Add SVG's and PNG's to your shared Xamarin Project
MIT License
318 stars 31 forks source link

Build size skyrocketed #12

Open AntvissMedia opened 4 years ago

AntvissMedia commented 4 years ago

My project has only about 30 png assets. I tried the library and followed the steps to set the BaseSize in the csproj file.

Removed my assets from the android project and included them all in the shared project with the right property as instructed.

Cleaned the project, deleted obj and bin folders everywhere and started a clean build.

The build took >45 mins (when a regular build wouldn't take more than 2mins) and the build size was 350mb up from the normal 27mb.

beeradmoore commented 4 years ago

Are you able to put these assets in a blank forms project and replicate that issue?

Redth commented 4 years ago

Yeah need some more context here... Posting a binlog would be helpful.

AntvissMedia commented 4 years ago

Oh God, I wrote the reply initially after @beeradmoore messaged me and it looks like I didn't press send. I have moved on to using the xamarin embedded resources so no longer have the sample to share. Happy for you to close it if no one else reported the issue.

=== Previous reply

I can confirm that using the same assets in a blank forms project (forms, ios and android) behaves the same.

Steps to replicate:

Redth commented 4 years ago

You mean you see the same behaviour without Resizetizer installed, in a normal forms app?

AntvissMedia commented 4 years ago

No, without Resizetizer the apk was 18mb. After installing the nuget package and configuring the assets for Resizetizer the next build was over 200mb. No additional changes have been made to the default project apart from adding the nuget package and moving the assets from the android resources folder to the shared project and changing the properties for each.

IvoKrugers commented 4 years ago

I've got the same problem. Build takes over 30 minutes... Here is a sample project to reproduce the problem.

Redth commented 4 years ago

@IvoKrugers thanks for the repro, this is helpful!

It looks like you have a fair amount of bigger images which do just take some time to process, and so resizetizer itself is taking about 10s on android to do this work.

Aapt2 on the other hand is taking 3+ minutes...

We are looking at this to see if there's anything obvious causing it!

Redth commented 4 years ago

@IvoKrugers you are setting BaseSize="515,641" is this the actual size you are using in your code? (eg: <Image Source="Calfskin-Cover.png" WidthRequest="515" HeightRequest="641" />).

That's the first thing I'd check, BaseSize should be the size you intend to use in code.

If that is the case, the next thing I can see is Resizetizer is scaling those images up to larger sizes to produce HDPI, XHDPI, XXHDPI, XXXHDPI resolutions which is a bug and I should ignore the cases where the image is being upscaled as it doesn't really make sense to do that, we can just let the device load the largest available resolution images at runtime and not pre-scale them up.