Repository navigation
Description
The Google C++ style guide recommends the usage of absl in many cases but we do not have it available in the flutter engine. In some cases this has caused us to duplicate and maintain similar functionality in fml (example: fml::SharedMutex and fml::Status), in other cases it has hurt our designs (example: IsValid() methods in impeller instead of using absl::status_or).
@zanderso has made a good point that we should be careful about binary size. This could be a problem especially if we use absl's offerings simultaneously with fml offerings which is complicated by the upfront cost to migrate existing code.
Chromium has already adopted absl so it should be easy to drop in technically.
There may some functionality in absl that doesn't exist today that could help us too. I don't have experience with absl::GetStackTrace, but just the other day a user was asking for stacktraces when debugging c++ asserts. If that works on any of our target platforms that could save us some debugging time too if FML_CHECK's print out the stacktrace in debug builds. I didn't explore more potential usages since what I've listed already seems valuable enough.
cc @matanlurey
Activity
matanlurey commentedon Sep 14, 2023
Very supportive!
I suspect if e increase base binary size by:
johnmccutchan commentedon Sep 14, 2023
Some other benefits of absl:
I think if we adopted absl we should drop FML as there is a lot of overlap
zanderso commentedon Sep 14, 2023
We DEPS it in https://github.com/flutter/engine/blob/main/DEPS#L640, but I'm not sure where it's currently used.
There's a danger in doing any kind of gradual migration in that we won't be able to attribute binary size increases to it without proactive investigation (which may occur too late to do anything about it). I'm interested in thoughts on how to mitigate that. As a straw man, maybe some macros or typedefs could select between std:: maps/sets and absl:: maps/sets ?
chinmaygarde commentedon Sep 14, 2023
We are already using Abseil. Among other things, for backtraces. So far, we have preferred libc++ then base. Abseil was open sourced after Flutter was using FML/FXL but the use case seems similar to base. Not sure we can get rid of base altogether.
Since we have already deps it in, is there anything to do with this issue?
matanlurey commentedon Sep 14, 2023
@chinmaygarde:
@zanderso, if that's the case ^, then it's already part of our binary and I think as long as we remove the FML constructs as we migrate, it shouldn't be a problem? Alternatively we could do it one symbol/class/method at a time and do binary size snapshot checks if we're super concerned.
ABSL itself might have data on how large they are.
zanderso commentedon Sep 14, 2023
Since we link with linker GC/tree-shaking, the current binary size includes only the bits we use. If we use more of absl, linker gc will gc less stuff. There's a separate incremental cost when applying templates e.g. maps/sets to more types. That is, there isn't just a one-time fixed cost, but rather an incremental cost each time a templated class is applied to new template arguments. The templates are generative.
gaaclarke commentedon Sep 14, 2023
Do we need an autoroller? We should have at least established guidance on when and how to use it since there is some concern about using it without forethought with respect to binary size.
chinmaygarde commentedon Sep 14, 2023
The style guide doesn't recommend Abseil. But it does mention Abseil in its examples and some of the constructs are really useful and I wish we had this available since inception. Having said that, IMO we should use Abseil constructs if:
We have a lot of code to migrate in hard to reach places (like Fuchsia) that a complete removal of FML is going to be a yak shave that seems too daunting for the gains. And having a mix of libc++, FML, and absl constructs is confusing in itself.
matanlurey commentedon Sep 14, 2023
Ostensibly we're removing some of those pieces of code in the next year.
Definitely not suggesting "let's do it next quarter", but should we maintain FML instead of using ABSL? Absolutely not, IMO.
gaaclarke commentedon Sep 15, 2023
abslcan't be freely used today for 2 minor reasons:__has_trivial_assignI'll take a quick stab at making it shipshape.
gaaclarke commentedon Sep 15, 2023
Fixing the include structure is easy, the deprecation errors are not easy to get rid of though. I tried merging upstream to see if they were fixed there, but they weren't. I tried to start migrating the deprecated builtin functions, but I started getting weird static assertions like:
int32_tdefinitely should be trivially copyable.It got involved enough that I decided to drop it until we have a clear case driving the change. Worse case scenario we can push and pop pragmas to disable the deprecation errors around the includes. But I don't imagine people will be happy with that. There is a bit of a catch 22 where people won't use
absl::StatusOrbecause it isn't readily available but we won't addabsl::StatusOruntil it's used.[engine] Replace fml::Status and fml::StatusOr with absl (flutter#194161
[engine] Replace fml::Status and fml::StatusOr with absl (flutter#194161