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.

IllegalArgumentException before laying out ViewTapTarget on Marshmallow

See original GitHub issue
  • I have verified the issue exists on the latest version
  • I am able to reproduce it

Version used: 1.6.0

Stack trace:

Process: com.soundcloud.android.debug, PID: 2383 
java.lang.IllegalArgumentException: width and height must be > 0                                                                              
   at android.graphics.Bitmap.createBitmap(Bitmap.java:855)                                                                              
   at android.graphics.Bitmap.createBitmap(Bitmap.java:834)                                                                              
   at android.graphics.Bitmap.createBitmap(Bitmap.java:801)                                                                              
   at com.getkeepsafe.taptargetview.ViewTapTarget$1.run(ViewTapTarget.java:47)                                                                              
   at com.getkeepsafe.taptargetview.ViewUtil$1.onGlobalLayout(ViewUtil.java:60)                                                                              
   at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:912)                                                                              
   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1981)                                                                              
   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1119)                                                                              
   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6060)                                                                              
   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)                                                                              
   at android.view.Choreographer.doCallbacks(Choreographer.java:670)                                                                              
   at android.view.Choreographer.doFrame(Choreographer.java:606)                                                                              
   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)                                                                              
   at android.os.Handler.handleCallback(Handler.java:746)                                                                              
   at android.os.Handler.dispatchMessage(Handler.java:95)                                                                              
   at android.os.Looper.loop(Looper.java:148)                                                                              
   at android.app.ActivityThread.main(ActivityThread.java:5443)                                                                              
   at java.lang.reflect.Method.invoke(Native Method)                                                                              
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)                                                                              
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

Android version: 6.0 Marshmallow

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
xiphirxcommented, Dec 19, 2016

I see… Not sure what to do about this at the moment. It seems like an edge case I would need to get more user reports about for it to be worth caring about. I’ll close this issue in the meantime.

0reactions
juliozcommented, Dec 19, 2016

I’m guessing it is the result of a race condition. The View I’m targeting is held by an AppBarLayout and the animation I refer to is the expand/collapse animation that happens between states. Interestingly enough, this is the code for the setExpanded method in AOSP:

public void setExpanded(boolean expanded) {
    setExpanded(expanded, ViewCompat.isLaidOut(this));
}

While the following call goes to:

public void setExpanded(boolean expanded, boolean animate) {
    mPendingAction = (expanded ? PENDING_ACTION_EXPANDED : PENDING_ACTION_COLLAPSED)
                | (animate ? PENDING_ACTION_ANIMATE_ENABLED : 0);
    requestLayout();
}

Unfortunately there is this mPendingAction flag that will result in a state change as a consequence of the requestLayout call. As you can see, it is not a simple case as I cannot really control the animation nor the view rendering in that AppBarLayout unfortunately, but it might be the case that the ViewTapTarget is trying to set itself before the completion of the animation in the AppBarLayout. Sometimes it doesn’t happen, though, which makes me believe there is a race condition in there (specially because we’re using a separate Runnable to control GlobalLayouting).

Read more comments on GitHub >

github_iconTop Results From Across the Web

IllegalArgumentException (Java Platform SE 7 )
public class IllegalArgumentException extends RuntimeException. Thrown to indicate that a method has been passed an illegal or inappropriate argument.
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