Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the way the Compose interop works to avoid Android 12 bug (#1370)
* The way the composeEpoxyModel funtion was written it would create a function that looked like this (in decompiled dex bytecode) ``` public static final ComposeEpoxyModel composeEpoxyModel(String id, Object[] keys, Function2<? super Composer, ? super Integer, Unit> composeFunction) { ... ComposeEpoxyModel $this$composeEpoxyModel_u24lambda_u240 = new ComposeEpoxyModel(Arrays.copyOf(keys, keys.length), composeFunction); $this$composeEpoxyModel_u24lambda_u240.id(id); return $this$composeEpoxyModel_u24lambda_u240; } ``` this would trigger a ART bug in the (non mainline patched version of Android 12) to optimize the this line ``` $this$composeEpoxyModel_u24lambda_u240.id(id); ``` and lead to crashes on Android 12. More background at: #1199 and https://issuetracker.google.com/issues/197818595 This works around this issue by making sure that the creation, setting the id and adding to the controller of a ComposeEpoxyModelis happening in the same location in compiled bytecode. Note: If you run R8 with optimization enabled, outlining might still outline some of that inlined code again and thus still cause this probblem but that is a different issue that can be dealed with by disabling outlining or all optimization. * Fix lint error --------- Co-authored-by: Andreas Rossbacher <[email protected]>
- Loading branch information