eudycontreras / skeleton-bones Goto Github PK
View Code? Open in Web Editor NEWLibrary for dynamically generating skeleton loader drawables for Layouts and Views
License: MIT License
Library for dynamically generating skeleton loader drawables for Layouts and Views
License: MIT License
Describe the bug
After about 50 display-rotations, there is a significant increase in memory-usage of the sample-app in the demo-2 branch.
After the initial start of the app on an API-29 emulator, the usage was about 80mb.
After the rotation-marathon, it peaked to about 148mb. After the last rotation, in rest, the usage only went down to around 129mb.
It took around 2:30 minutes to reproduce this level of memory leakage.
If I can do something to help reproduce or fix the issue, please let me know.
This is the best skeleton-library I have found so far (and the only one working comfortably with CardViews in RecyclerView, for sure), so I still want to use it in our app-project.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expected the memory usage to stay around 80mb. In my own app-project, my app is itself also around 80mb and stays there with 4 RecyclerViews loading stuff from the internet. Integrating the Skeleton-Bones library shows the same behavior as in the sample-app, memory increased to the double amount after 40-50 rotations. This should not happen.
Smartphone (please complete the following information):
Additional context
I did an analysis of the sample-app demo-2 with LeakCanary as described here:
https://square.github.io/leakcanary/fundamentals-fixing-a-memory-leak/#3-find-the-reference-causing-the-leak
The LeakCanary-dump is this:
skeleton-bones-demo2-sample-leak.log
Hi,
I'm using version 1.4.1, and today I'm seeing new version 1.4.4. I was upgrade to this version and my code is didn't working.
Please give me a standard way to use library, I don't use data-binding
And more, If I use library, my view has an issue, method visible of View is not working.
java.lang.IllegalArgumentException: parameter must be a descendant of this view
at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:6388)
at android.view.ViewGroup.offsetDescendantRectToMyCoords(ViewGroup.java:6317)
at com.eudycontreras.boneslibrary.framework.skeletons.SkeletonBone.recompute(SkeletonBone.kt:91)
at com.eudycontreras.boneslibrary.framework.skeletons.Skeleton.recomputeAndBuild(Skeleton.kt:194)
at com.eudycontreras.boneslibrary.framework.skeletons.Skeleton.onUpdate(Skeleton.kt:96)
at com.eudycontreras.boneslibrary.framework.skeletons.SkeletonRenderer.update(SkeletonRenderer.kt:27)
at com.eudycontreras.boneslibrary.framework.skeletons.SkeletonManager$startAnimation$1.invoke(SkeletonManager.kt:194)
at com.eudycontreras.boneslibrary.framework.skeletons.SkeletonManager$startAnimation$1.invoke(SkeletonManager.kt:22)
at com.eudycontreras.boneslibrary.extensions.AnimatorExtensionsKt$animate$3.onAnimationUpdate(AnimatorExtensions.kt:71)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1579)
at android.animation.ValueAnimator.animateBasedOnTime(ValueAnimator.java:1357)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1502)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1230)
at android.view.Choreographer.doCallbacks(Choreographer.java:1029)
at android.view.Choreographer.doFrame(Choreographer.java:925)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1217)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:233)
at android.os.Looper.loop(Looper.java:344)
at android.app.ActivityThread.main(ActivityThread.java:8212)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034)
Describe the bug
Everything works fine when building directly from Android Studio, but as soon as we made a release build, we got a crash:
Fatal Exception: java.lang.IllegalArgumentException: The key must be an application-specific resource id.
at android.view.View.setTag(View.java:26098)
at com.eudycontreras.boneslibrary.extensions.ViewExtensionsKt.clearProps(ViewExtensionsKt.java:153)
at com.eudycontreras.boneslibrary.framework.bones.BoneDrawable$initialize$4.invoke(BoneDrawable.kt:179)
at com.eudycontreras.boneslibrary.framework.bones.BoneDrawable$initialize$4.invoke(BoneDrawable.kt:94)
at com.eudycontreras.boneslibrary.framework.bones.BoneManager.dispose(BoneManager.kt:108)
at com.eudycontreras.boneslibrary.framework.bones.BoneManager$animateFadeOut$3.invoke(BoneManager.kt:166)
at com.eudycontreras.boneslibrary.framework.bones.BoneManager$animateFadeOut$3.invoke(BoneManager.kt:23)
at com.eudycontreras.boneslibrary.extensions.AnimatorExtensionsKt$animate$$inlined$addListener$1.onAnimationEnd(Animator.kt:117)
at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:600)
at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1333)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1575)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:307)
at android.animation.AnimationHandler.-$$Nest$mdoAnimationFrame(AnimationHandler.java)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:86)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1229)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1239)
at android.view.Choreographer.doCallbacks(Choreographer.java:899)
at android.view.Choreographer.doFrame(Choreographer.java:827)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1214)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
We fixed this by adding the following line to our app's proguard-rules.pro:
-keep class com.eudycontreras.boneslibrary.framework.bones.BoneProperties { *; }
This was hard to debug, so it would be nice if this line was just added the the proguard-rules file in the library instead :)
Smartphone (please complete the following information):
This is my code
skeletonBuilder = SkeletonDrawable.create(view as ViewGroup)
.builder()
.setEnabled(true)
.setAllowSavedState(true)
.withShimmerBuilder {
setColor(MutableColor.fromColor(colorGray300))
setCount(3)
}
hide effect
skeletonBuilder?.setEnabled(false)
Today, I upgrade version from 1.4.1 to 1.4.5 and it doesn't working. How to disable the effect?
Thank for your great repository. I use your repo to create skeleton for screens in my app but how can i revert the screens to origin state after making them skeleton. Hope to hear your response. Sincerely, thank you.
Caused by: kotlin.UninitializedPropertyAccessException: lateinit property renderer has not been initialized
at com.eudycontreras.boneslibrary.framework.bones.BoneManager.getRenderer(BoneManager.kt:31)
at com.eudycontreras.boneslibrary.framework.bones.BoneManager.stopAnimation(BoneManager.kt:205)
at com.eudycontreras.boneslibrary.framework.bones.BoneManager.dispose(BoneManager.kt:102)
at com.eudycontreras.boneslibrary.framework.bones.BoneManager.resetForReuse(BoneManager.kt:95)
at com.eudycontreras.boneslibrary.framework.bones.BoneDrawable.resetForReuse(BoneDrawable.kt:275)
at com.eudycontreras.boneslibrary.bindings.SkeletonBoneBindingsKt.addBoneLoader(SkeletonBoneBindings.kt:187)
at com.eudycontreras.boneslibrary.framework.bones.BoneDrawable.enable(BoneDrawable.kt:267)
at com.eudycontreras.bones.Skeleton.createIfNeeded(Skeleton.kt:74)
at com.eudycontreras.bones.TestActivity.onCreate(TestActivity.kt:43)
at android.app.Activity.performCreate(Activity.java:8129)
at android.app.Activity.performCreate(Activity.java:8109)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1344)
thank you for your awesome library
how can I use it on my RecyclerView and set the specific items for shimmer
I'm trying to use your lib without databindings with just SkeletonDrawable class. It works, but for some reason it creates skeleton without animation, just bones. And also it doesn't ingnore views which I pass through withIgnoredBones()
. So I have a question: what am I doing wrong? Here is my code, it runs in onViewCreated()
of my fragment.
SkeletonDrawable.create(contentCl, true)
.builder()
.setAnimateRestoreBounds(true)
.setAllowSavedState(true)
.withIgnoredBones(R.id.cancelIv)
.withShimmerBuilder {
setInterpolator(AccelerateInterpolator())
setSpeedMultiplier(1F)
setSharedInterpolator(true)
setThickness(120.dp)
setThickness(10.dp)
setTilt(-0.2f)
}
Thank for library, but I have an issue.
I use this code in my fragment
skeletonBuilder = SkeletonDrawable.create(fragmentRootView)
.build()
.setEnabled(true)
.setAllowSavedState(true)
And this is result (image below)
My fragment has skeleton loading effect, but I want to change color green to gray?
Thanks.
First thanks for what seems like a great library with great technical solution to the problem and good documentation as well.
But I can't get it to work, so I have a few questions/bug findings:
SkeletonDrawable.create(this).apply {
this.getProps().apply {
this.enabled = true
this.allowSavedState = true
this.shimmerRayProperties.apply {
this.shimmerRayThickness = 10.dp
this.shimmerRayTilt = 0.3f
}
}
}
SkeletonDrawable.create(this)
.build()
.setEnabled(true)
.setAllowSavedState(true)
.withShimmerBuilder {
setThickness(10.dp)
setTilt(0.3f)
setAnimationDuration(300L)
}
.setCornerRadii(3f)
.setColor(MutableColor(appCtx.getColor(R.color.green)))
.withBoneBuilder(generateId()) {
setColor(MutableColor(appCtx.getColor(R.color.lemon)))
setMaxThickness(12.dp)
setMinThickness(10.dp)
setCornerRadii(CornerRadii(3f))
setEnabled(true)
setTransitionDuration(300L)
}
.setUseStateTransition(true)
app:skeletonGenerateBones
app:skeletonAnimateRestoredBounds
Thanks for creating this library. I just started to play with it and it looks promising.
Describe the bug
When using attribute skeletonBoneIgnored
the binding adapter method setSkeletonIgnored()
looks for the parent skeleton drawable to store the ignored id by calling getParentSkeletonDrawable()
. If the parent skeleton drawable is not found nothing happens and the view is not ignored.
There is no guaranteed order of execution in Android data binding as stated here. Thus the call to setSkeletonIgnored()
can occurs before the call to setSkeletonEnabled()
or other binding adapter methods who creates the skeleton drawable and the view won't be ignored.
Expected behavior
The view with skeletonBoneIgnored="@{true}"
is ignored.
Additional context
Other binding adapter methods may be affected by this behavior. I think it also happens for skeletonBoneHeight
,skeletonBoneMinHeight
A workaround is to immediately create the SkeletonDrawable
programmatically just after inflating the layout.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.