You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So it looks like the sizes of the Skia library come to about 20 MB for Android and 13 MB for IOS. Is there any way to reduce this by creating custom builds or by another method?
I think, after looking at this, the Android is a bit large. I must have a look at what gyp is doing when it generates the project. It might be the case that the build is wrong as with Windows: mono/skia#25
I tried a few things, but I can't seem to reduce the size at all. Right now, it IS building release with optimizations, yet it is 15MB vs Windows's 5MB and iOS's 8MB
@laarmen, thanks for that link. It was very helpful in confirming some not-so-great news. The NDK build already strips the output 😞
The actual size before stripping is ~35-40 MB and this gets stripped to ~13-16. I tried re-stripping the builds, and stripping all debug and other unused symbols, but was unable to reduce the size.
Let me look some more... i think i found that if I run strip after the build, then i can get an iOS arch from 11.5MB to 7.5MB. I need check that all works still, and nothing is getting stripped away.
I have managed to drop iOS/tvOS quite a bit to ~5MB per arch - which is the same as Windows/UWP. macOS is a bit smaller at ~15MB per arch and Android is ~12MB per arch. As I am looking at Linux as well (#90) I notice that it is also ~16MB per arch. I still want to see why Linux/Android/macOS are so much larger, even with the same strict compile/link flags. I even made everything private and am just keeping the C API public (size did drop a bit).
Basically, everything is ~5MB, except the macOS/Android/Linux builds which are ~15MB.
@kekekeks were you linking in the GPU bits skgpu=1.
And, are you able to see what size your build is when you link this stuff in: native-builds/libSkiaSharp_android/jni/SkiaSharp.mk (also not that those flags in the makefile only apply to the final library, not all the others)
Ah, thanks @djcparker@mattleibow! I've made Jon Douglas (Xamarin) aware of this because I was liaising with him yesterday on this issue. I'll report back if I can get a confirmation it's fixed in alpha.
I am sure this was fixed. You should try archiving your app. It may not reduce the app size if you are running in Debug to reduce compile times, but I am able to get my app reduced if I Archive, even when I just set the linker to "Link SDK assemblies only".
@mattleibow I am building with Bitrise. Prior to 15.2 my APK was ~30MB. With 15.2 and no code changes, it's now ~40MB. Cracking open the APK and looking inside shows that the native code is in two places: inside lib and also embedded as a resource inside SkiaSharp.dll. This is true of both stable Xamarin and alpha Xamarin. The bug report is CONFIRMED with no mention of a fix being in place in any channel yet.
@mattleibow I work locally with VS, but I don't use that to produce productions APKs/IPAs - they always come through Bitrise. So I'd be comparing apples to oranges if I looked at my VS output.
Hmmm, I wonder whether it has to do with the Bitrise images. They've upgraded to 15.2.2, but they do not yet include VS4Mac, only XS. There's a small chance that's a factor. Bitrise plan to include VS4Mac in their images sometime in the next week or two. Once they've done that, I'll report back here as to whether that rectifies the problem.
All the same, Xamarin have confirmed it is an issue, so I assume it still is.
@kentcb I just built Release of my sample app using the stable VS and everything appears to be fine. No need for anything fancy, I just did a plain old Release build on Any CPU. I will point out that the SkiaSharp.dll in the bin folder STILL has the embedded native libraries (9MB), but the one in the .apk does not (200KB).
Does my sample work for you locally in VS? And in your Bitrise build, could you send ([email protected]) the build log? I will have a look and see what is up.
Hello, this is crazy. using version 1.60.0, it ads 3,8 mb size while 1.60.1 adds 9mb.. what has changed in between? you didnt even increase major version number. it cant be such a big difference. see this issue
@EmilAlipiev thanks for reporting this. The build system changed a fair bit and the stripping may have fallen back to the original settings. I opened a new issue #573 and I will see if I can get this resolved ASAP.
Activity
djcparker commentedon Oct 28, 2016
same question from me. 20MB for Android is pretty heavy.
btw; Matt - loving SkiaSharp - awesome job!
thanks
Dave
mattleibow commentedon Oct 28, 2016
Just to note the average sizes per platform architecture:
mattleibow commentedon Oct 28, 2016
I think, after looking at this, the Android is a bit large. I must have a look at what gyp is doing when it generates the project. It might be the case that the build is wrong as with Windows: mono/skia#25
mattleibow commentedon Oct 28, 2016
I tried a few things, but I can't seem to reduce the size at all. Right now, it IS building release with optimizations, yet it is 15MB vs Windows's 5MB and iOS's 8MB
djcparker commentedon Oct 30, 2016
it is a big difference.
The realm.io guys had an interesting post on native sizes: reducing apk size, not sure if it is relevant as I haven't pulled the apk apart..
For me, between skia and a few other packages my app is a 40MB download.
mattleibow commentedon Oct 31, 2016
@djcparker Thanks for those links, trying some options now.
I'll see if I can get a doc together to help with ideas for reducing apk sizes
laarmen commentedon Nov 30, 2016
While researching the subject, I saw this: https://groups.google.com/forum/#!topic/skia-discuss/5hNRcmERVSI
mattleibow commentedon Dec 2, 2016
@laarmen, thanks for that link. It was very helpful in confirming some not-so-great news. The NDK build already strips the output 😞
The actual size before stripping is ~35-40 MB and this gets stripped to ~13-16. I tried re-stripping the builds, and stripping all debug and other unused symbols, but was unable to reduce the size.
kekekeks commentedon Jan 26, 2017
@mattleibow
Try to compile with
-ffunction-sections -fdata-sections -fno-rtti, link with-gc-sections.mattleibow commentedon Jan 27, 2017
I changed the build scripts, and managed to get an overall reduction of about 4MB on Android, 2.5MB on iOS, 2.5MB on macOS and 1MB for tvOS.
Not a big drop, but the new sizes are:
@kekekeks have you been able to get smaller files? I am building and linking almost everything in: core, pdf, svg, codecs, intrinsics.
kekekeks commentedon Jan 27, 2017
The smallest of my buillds was 1.7MB for arm32 Android. I was not explicitly excluding anything from build, just linked unused stuff away.
mattleibow commentedon Jan 27, 2017
Let me look some more... i think i found that if I run strip after the build, then i can get an iOS arch from 11.5MB to 7.5MB. I need check that all works still, and nothing is getting stripped away.
mattleibow commentedon Jan 28, 2017
I have managed to drop iOS/tvOS quite a bit to ~5MB per arch - which is the same as Windows/UWP. macOS is a bit smaller at ~15MB per arch and Android is ~12MB per arch. As I am looking at Linux as well (#90) I notice that it is also ~16MB per arch. I still want to see why Linux/Android/macOS are so much larger, even with the same strict compile/link flags. I even made everything private and am just keeping the C API public (size did drop a bit).
Basically, everything is ~5MB, except the macOS/Android/Linux builds which are ~15MB.
@kekekeks were you linking in the GPU bits
skgpu=1.And, are you able to see what size your build is when you link this stuff in: native-builds/libSkiaSharp_android/jni/SkiaSharp.mk (also not that those flags in the makefile only apply to the final library, not all the others)
29 remaining items
kentcb commentedon May 30, 2017
Ah, thanks @djcparker @mattleibow! I've made Jon Douglas (Xamarin) aware of this because I was liaising with him yesterday on this issue. I'll report back if I can get a confirmation it's fixed in alpha.
kentcb commentedon May 30, 2017
OK, tried switching Bitrise to alpha channel and rebuilding. Unfortunately, it still produces a bloated APK :(
djcparker commentedon May 30, 2017
@kentcb :( not good.
mattleibow commentedon May 30, 2017
I am sure this was fixed. You should try archiving your app. It may not reduce the app size if you are running in Debug to reduce compile times, but I am able to get my app reduced if I Archive, even when I just set the linker to "Link SDK assemblies only".
This is my test app: https://github.com/mattleibow/SkiaSharpDemo
djcparker commentedon May 30, 2017
Hmmm, ok. Will try the latest alpha :)
kentcb commentedon May 31, 2017
@mattleibow I am building with Bitrise. Prior to 15.2 my APK was ~30MB. With 15.2 and no code changes, it's now ~40MB. Cracking open the APK and looking inside shows that the native code is in two places: inside lib and also embedded as a resource inside SkiaSharp.dll. This is true of both stable Xamarin and alpha Xamarin. The bug report is CONFIRMED with no mention of a fix being in place in any channel yet.
mattleibow commentedon May 31, 2017
@kentcb If you build my sample app (https://github.com/mattleibow/SkiaSharpDemo) does the same thing happen? I can't seem to reproduce when running "Archive for Publishing".
What is your IDE and your version numbers?
Mine are: https://gist.github.com/mattleibow/bff95014b9cee90c828a67f1ed335fc7
kentcb commentedon May 31, 2017
@mattleibow I work locally with VS, but I don't use that to produce productions APKs/IPAs - they always come through Bitrise. So I'd be comparing apples to oranges if I looked at my VS output.
Hmmm, I wonder whether it has to do with the Bitrise images. They've upgraded to 15.2.2, but they do not yet include VS4Mac, only XS. There's a small chance that's a factor. Bitrise plan to include VS4Mac in their images sometime in the next week or two. Once they've done that, I'll report back here as to whether that rectifies the problem.
All the same, Xamarin have confirmed it is an issue, so I assume it still is.
mattleibow commentedon Jun 1, 2017
@kentcb I just built Release of my sample app using the stable VS and everything appears to be fine. No need for anything fancy, I just did a plain old Release build on Any CPU. I will point out that the SkiaSharp.dll in the bin folder STILL has the embedded native libraries (9MB), but the one in the .apk does not (200KB).
Does my sample work for you locally in VS? And in your Bitrise build, could you send ([email protected]) the build log? I will have a look and see what is up.
Here is my VS config:
https://gist.github.com/mattleibow/8395177ffec5f0ef61d95ccf0eb0dfe3
kentcb commentedon Jun 22, 2017
@mattleibow interestingly, my APK dropped from 45MB to 35MB again today when I merged my branch to switch us to netstandard and SDK-style csproj 🤔
EmilAlipiev commentedon Jul 1, 2018
Hello, this is crazy. using version 1.60.0, it ads 3,8 mb size while 1.60.1 adds 9mb.. what has changed in between? you didnt even increase major version number. it cant be such a big difference. see this issue
luberda-molinet/FFImageLoading#893
mattleibow commentedon Jul 3, 2018
@EmilAlipiev thanks for reporting this. The build system changed a fair bit and the stripping may have fallen back to the original settings. I opened a new issue #573 and I will see if I can get this resolved ASAP.
mattleibow commentedon Jul 3, 2018
Could all new comments be made on the new issue so we can track them with the next release.
EmilAlipiev commentedon Nov 30, 2020
I think that size was increased also from 3mb to 5mb between 1.6x version to 2.8x version. it is not a big number but i want to just inform you :)