firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.52k stars 1.44k forks source link

[FR]: Avoid if it's possible hardcoded strings to reduce framework size #13295

Open jesus-mg-ios opened 1 month ago

jesus-mg-ios commented 1 month ago

Description

I'm wondering if is possible reduce the comments in asserts and string hardcoded that could have no impact in clients sdks, because they are for development purposes. Doing this the binary size could be reduced.

As examples, of what a binary nowadays contains because it uses firebase. https://github.com/firebase/firebase-ios-sdk/blob/fcdb55405b7f4c32d0068f902fac42defe63fefd/Firestore/core/src/remote/exponential_backoff.cc#L68 https://github.com/firebase/firebase-ios-sdk/blob/fcdb55405b7f4c32d0068f902fac42defe63fefd/Firestore/core/src/util/filesystem_win.cc#L137 https://github.com/firebase/firebase-ios-sdk/blob/fcdb55405b7f4c32d0068f902fac42defe63fefd/Firestore/Source/API/FSTUserDataReader.mm#L296 https://github.com/firebase/firebase-ios-sdk/blob/fcdb55405b7f4c32d0068f902fac42defe63fefd/Firestore/Source/API/FSTUserDataReader.mm#L584 https://github.com/firebase/firebase-ios-sdk/blob/fcdb55405b7f4c32d0068f902fac42defe63fefd/Firestore/core/src/util/random_access_queue.h#L111

API Proposal

No response

Firebase Product(s)

AB Testing, Analytics, App Check, App Distribution, Authentication, Crashlytics, Database, DynamicLinks, Firestore, Functions, In-App Messaging, Installations, ML Model Downloader, Messaging, Performance, Remote Config, Storage, Vertex AI

google-oss-bot commented 1 month ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

paulb777 commented 1 month ago

In Objective C, asserts are compiled out in release mode. It looks like we do something different in C++ code.

dconeybe commented 1 month ago

Hi @jesus-mg-ios. Could you elaborate on your desire to reduce your binary size? We hear this request often for our web SDKs, which are incredibly sensitive to code size; however, this is an unusual request for an iOS SDK. Have you measured the binary size reduction that would be gained from stripping out these strings? My gut tells me that the size saved would be negligible compared to the size of an entire IPA.

jesus-mg-ios commented 1 month ago

It's a combined effort. We haven't specifically counted how many strings are leaked into Firestore and other binaries that might not make sense or work in production. You know there's an alert when you try to download an app over 200 MB without a Wi-Fi connection from the App Store. We're working to reduce the size to be under this limit because it impacts downloads. So, we're addressing various areas and working with other third parties as well. Any reduction you can make in the size of your binaries would be greatly appreciated.

You can double check the total of strings using the strings command over firebase binaries and then have an idea about it. It doesn't mean that the total of the strings on it is the total of strings leaked, but then you can filter the list with some kinda list you provide about strings used in firebase binaries

dconeybe commented 1 month ago

That's an interesting motivation to reduce code size. I can see how that "warning" dialog could negatively impact download count.

We went through a similar exercise on the Firestore JS SDK, stripping out assertion messages to reduce code size. But that only reduced code size on the order of kilobytes. Again, my gut instinct is that even if we stripped out all messages it would save max 1 or 2 MB. That being said, it would need to be measured to know for sure.

I'll bring this up with the team and see if, and how, we want to proceed with this request.

jesus-mg-ios commented 1 month ago

Thanks for your effort @dconeybe it's much appreciated.