Crash from CardStackLayoutManager.updateScale: Cannot set `scaleX` to Float.NaN
See original GitHub issueHi, sorry if this has been logged before, but I couldn’t find it in search 😄 We’re seeing crash reports with the following stack trace:
Fatal Exception: java.lang.IllegalArgumentException: Cannot set 'scaleX' to Float.NaN
at android.view.View.sanitizeFloatPropertyValue(View.java:16979)
at android.view.View.sanitizeFloatPropertyValue(View.java:16953)
at android.view.View.setScaleX(View.java:16342)
at com.yuyakaido.android.cardstackview.CardStackLayoutManager.updateScale(CardStackLayoutManager.java:411)
at com.yuyakaido.android.cardstackview.CardStackLayoutManager.update(CardStackLayoutManager.java:338)
at com.yuyakaido.android.cardstackview.CardStackLayoutManager.onLayoutChildren(CardStackLayoutManager.java:50)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
at androidx.recyclerview.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1858)
at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:5044)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer.doFrame(Choreographer.java:693)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:6981)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
The integration with CardStackView & CardStackLayoutManager is not too complex:
swipeLayoutManager = new CardStackLayoutManager(requireContext(), this);
swipeLayoutManager.setStackFrom(StackFrom.Top);
swipeLayoutManager.setMaxDegree(30.0f);
swipeRecyclerView.setLayoutManager(swipeLayoutManager);
if (savedInstanceState != null) {
final int currentPosition = savedInstanceState.getInt(STATE_CARD_POSITION);
swipeLayoutManager.scrollToPosition(currentPosition);
}
I don’t know if I can post the full layout for our ViewHolders, but based on the stacktrace it doesn’t seem like anything in our layout would be causing this? Let me know if you think that would be helpful and I’ll see what I can do 👍
The line causing the crash is here:
Somehow targetScale
is being calculated to Float.NaN
. It’s not really clear to me how that’s possible. Does it make sense to sanitize the value calculated before passing into setScaleX
?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Cannot set 'scaleX' to Float.NaN - Google Groups
Hi all & Team,. is anyone facing the below crash while staring camera using bindToLifeCyle() api? ------- ...
Read more >Xamarin forms android 9 crash - Stack Overflow
IllegalArgumentException: 'Cannot set 'scaleX' to Float.NaN' . This error was because I was using ScaleTo() in async Task.
Read more >Cannot set 'scaleX' to Float.NaN And targetSdkVersion="30"
I have this error: java.lang.IllegalArgumentException: Cannot set 'scaleX' to Float.NaN but when I use android:targetSdkVersion="26" Fixed!
Read more >App crashes only on Dire Straits 'Private investigations'...
It's actually the only song that ever crashed the app on my phone. ... IllegalArgumentException: Cannot set 'scaleX' to Float.NaN
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I met this error now. I using an old version 1.0.0-beta5. Is this error appear on latest version @damien5314 ?
Try to use match_parent for the layout_width and layout_height of the card stack view.