question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash from CardStackLayoutManager.updateScale: Cannot set `scaleX` to Float.NaN

See original GitHub issue

Hi, 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:

https://github.com/yuyakaido/CardStackView/blob/b1b6053b7d0649189a1443fded2d7df70e7e4527/cardstackview/src/main/java/com/yuyakaido/android/cardstackview/CardStackLayoutManager.java#L420

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:open
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
trunghdocommented, Jun 24, 2019

I met this error now. I using an old version 1.0.0-beta5. Is this error appear on latest version @damien5314 ?

0reactions
JMS1208commented, Aug 6, 2022

Try to use match_parent for the layout_width and layout_height of the card stack view.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found