Status Update
Comments
cc...@google.com <cc...@google.com> #2
I've attached another 2 screenshots from the ShapeEditor view of one of the blobs, showing the shape and controls/anchors. You can see that the tighter bounds (yellow rectangle) are constrained to the anchors, but the curves at the end go beyond those points and exceed the bounds.
ap...@google.com <ap...@google.com> #3
But that's not all of the problem here. When I changed those min/max values to use the control points instead, the bounds expanded to be essentially the same as the estimated bounds from before. So there's more to it.
ch...@google.com <ch...@google.com> #4
Meanwhile, I thought part of the problem might be calculating derivatives/etc for zero-length curves (of which there are many, given the way our shape rounding works). But adding in a check for this (setting the bounds of a curve to the same point when the anchors are equal within the distance epsilon) did not fix the problem; we still end up with bounds that are inside some of the curves (see attached screenshot)
cc...@google.com <cc...@google.com> #5
Branch: androidx-main
commit 958577b15712233aa487003deb0ab37de3af7ab7
Author: Chet Haase <chet@google.com>
Date: Wed Dec 20 13:21:53 2023
Added more bounds calculation utilities
Previously, calculateBounds() returned the estimated bounds
for a RoundedPolygon. This is reasonable in most cases, but sometimes
you want the actual/minimal bounds instead. Also, sometimes you want
the max bounds for an object that might be rotated within its container,
so you need to size the container appropriately.
This CL introduces options for bounds calculations to handle these
new cases, along with some minor cleanups along the way.
Bug: 317286450
Test: Existing tests pass, added new bounds tests
Relnote: Now more options for retrieving exact and max bounds
Change-Id: I6d49f468a28c1f360000e8370f02a50841f744e4
M graphics/graphics-shapes/api/current.txt
M graphics/graphics-shapes/api/restricted_current.txt
M graphics/graphics-shapes/src/androidInstrumentedTest/kotlin/androidx/graphics/shapes/PolygonTest.kt
M graphics/graphics-shapes/src/commonMain/kotlin/androidx/graphics/shapes/Cubic.kt
M graphics/graphics-shapes/src/commonMain/kotlin/androidx/graphics/shapes/RoundedPolygon.kt
M graphics/graphics-shapes/src/commonMain/kotlin/androidx/graphics/shapes/Utils.kt
M graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/DebugDraw.kt
M graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/MainActivity.kt
ze...@google.com <ze...@google.com> #6
We also offer a new API, calculateMaxBounds(), which returns the square bounds in which the object can be rotated without ever exceeding the bounds.
cc...@google.com <cc...@google.com> #7
Is it possible for R8 to figure out which enum classes are potentially fed to such stl methods? If so, and the stl behavior is consistent (and stl using values to implement class.enumConstants seems reasonable), it would be nice to avoid this necessary configuration (even if studio gives it to you by default in the very stale proguard-android-optimize
list).
Either that, or could make enum value/valueOf minification opt-in.
ze...@google.com <ze...@google.com> #8
Unfortunately, we have not been able to come up with a safe/sound analysis that can determine when the rules are not needed. Conversely, we have no way of safely keeping the enums that is less conservative than the rules. There are clients that do not have these rules as they manually ensure that they have no usages of enums that would break. Thus we can't make the rules part of the compiler and we can't safely determine when they are needed. We are not happy with that situation, but we currently have no better alternatives.
cc...@google.com <cc...@google.com> #9
Fair enough, feel free to close as WAI. Understand that the cost to migrate the default is non-zero, with minimal benefit.
ch...@google.com <ch...@google.com>
pr...@google.com <pr...@google.com> #10
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.benchmark:benchmark-junit4:1.3.0-alpha05
Description
In tweaking proguard rules in androidx microbenchmarks, I noticed that some of our generated moshi code references to a values array are failing to resolve, and crashing at runtime:
Repro AndroidX CL, which just enables R8 in a trivial sample benchmark, and tweaks proguard rules to get it (almost) running:https://android-review.git.corp.google.com/c/platform/frameworks/support/+/3073538