-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent trace strings from getting created when tracing is disabled #2494
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be surprised if this makes a meaningful impact with all of the ART optimizations and background GC improvements over the years but this seems like a reasonable optimization.
@@ -112,8 +128,7 @@ protected float getInterpolatedCurrentKeyframeProgress() { | |||
Keyframe<K> keyframe = getCurrentKeyframe(); | |||
// Keyframe should not be null here but there seems to be a Xiaomi Android 10 specific crash. | |||
// https://github.com/airbnb/lottie-android/issues/2050 | |||
// https://github.com/airbnb/lottie-android/issues/2483 | |||
if (keyframe == null || keyframe.isStatic() || keyframe.interpolator == null) { | |||
if (keyframe == null || keyframe.isStatic()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave this PR to a single task. Could you revert this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this issue was actually caused by virtual machine optimizations. I tracked memory allocations using the ‘Profiler’ tools from Android stuido and observed a significant number of StringBuilder instances being created at the points where beginSection and endSection methods were called. When I tested the code of my PR, these StringBuilder instances no longer appeared, and the memory stabilized without causing frequent garbage collection.
My test code is follow,I just provided an INFINITE LottieAnimationView in the layout, and didn't do anything else。
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/assetView0"
android:layout_width="100dp"
android:layout_height="100dp"
app:lottie_autoPlay="true"
app:lottie_fileName="figure/data.json"
app:lottie_imageAssetsFolder="figure/images"
app:lottie_repeatCount="-1"/>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am Chinese and my English is not very good, so I may not fully understand your meaning or be able to respond clearly. I hope you can bear with me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is specifically referring to the addition you made here for keyframe.interpolator == null
which seems unrelated to the rest of the code in this PR.
…dSection methods.
0360e57
to
4af3e59
Compare
I fixed it.
At 2024-04-13 04:20:18, "Gabriel Peal" ***@***.***> wrote:
@gpeal commented on this pull request.
In lottie/src/main/java/com/airbnb/lottie/animation/keyframe/BaseKeyframeAnimation.java:
@@ -112,8 +128,7 @@ protected float getInterpolatedCurrentKeyframeProgress() {
Keyframe<K> keyframe = getCurrentKeyframe();
// Keyframe should not be null here but there seems to be a Xiaomi Android 10 specific crash.
// #2050
- // #2483
- if (keyframe == null || keyframe.isStatic() || keyframe.interpolator == null) {
+ if (keyframe == null || keyframe.isStatic()) {
This comment is specifically referring to the addition you made here for keyframe.interpolator == null which seems unrelated to the rest of the code in this PR.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
|
issue#2493