29jitender / Spotlight

Spotlight is an Android library used to onboard users by showcasing specific features in the app.
Apache License 2.0
1.27k stars 163 forks source link

#15 issue still exist #60

Open mayurwish opened 7 years ago

mayurwish commented 7 years ago

Reproduced on Android version: Android 7.0 Device: Galaxy S8+ (dream2lte) Manufacturer: Samsung RAM (MB) 4096 Screen size 1080 × 2008 Screen density (dpi) 420 Native platform armeabi-v7a OpenGL ES version 3.2 CPU make Samsung CPU model Exynos 8895

Fatal Exception: java.lang.IllegalStateException: Cannot start this animator on a detached view! at android.view.RenderNode.addAnimator(RenderNode.java:863) at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:300) at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:282) at android.animation.RevealAnimator.(RevealAnimator.java) at android.view.ViewAnimationUtils.createCircularReveal(ViewAnimationUtils.java:55) at com.wooplr.spotlight.SpotlightView.startRevealAnimation(SpotlightView.java:358) at com.wooplr.spotlight.SpotlightView.access$100(SpotlightView.java:54) at com.wooplr.spotlight.SpotlightView$1.run(SpotlightView.java:319) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:7409) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

tinyCoder32 commented 7 years ago

Here too.

dhavalwooplr commented 7 years ago

I added a possible fix based on crash logs and your suggestions in SpotlightView class.

private void show(final Activity activity) {

        if (preferencesManager.isDisplayed(usageId))
            return;

        ((ViewGroup) activity.getWindow().getDecorView()).addView(this);

        setReady(true);

        SpotlightView.this.post(new Runnable() {
            @Override
            public void run() {
                try{
                    boolean isAttachedToWindow = true;
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                        isAttachedToWindow = SpotlightView.this.isAttachedToWindow();
                    }

                    if(isAttachedToWindow) {
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

                            if (isRevealAnimationEnabled)
                                startRevealAnimation(activity);
                            else {
                                startFadinAnimation(activity);
                            }
                        } else {
                            startFadinAnimation(activity);
                        }
                    }
                }catch(Exception e){
                    e.printStackTrace();
                }
            }
        });
    }

I modified above method to avoid that crash but I'm unable to reproduce this issue and so unable to test this. Can you guys check this change in your code and confirm if this is the working fix for you or not?

rasheedk commented 7 years ago

Hi, dhavalwooplr

Crash issue is fixed by changing to your code above, but we can't show the tutorial [Spotlight View ] again if we use the above code....

Crash issue was found when :

Fatal Exception: java.lang.IllegalStateException: Cannot start this animator on a detached view! at android.view.RenderNode.addAnimator(RenderNode.java:812) at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:300) at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:282) at android.animation.RevealAnimator.<init>(RevealAnimator.java:37) at android.view.ViewAnimationUtils.createCircularReveal(ViewAnimationUtils.java:55) at com.wooplr.spotlight.SpotlightView.startRevealAnimation(SpotlightView.java:358) at com.wooplr.spotlight.SpotlightView.access$100(SpotlightView.java:54) at com.wooplr.spotlight.SpotlightView$1.run(SpotlightView.java:319) 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(Method.java)

What i have done to avoid crash

  1. Modified SpotlightView.java with your code below `SpotlightView.this.post(new Runnable() { @Override public void run() { try{ boolean isAttachedToWindow = true; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { isAttachedToWindow = SpotlightView.this.isAttachedToWindow(); }

                if(isAttachedToWindow) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    
                        if (isRevealAnimationEnabled)
                            startRevealAnimation(activity);
                        else {
                            startFadinAnimation(activity);
                        }
                    } else {
                        startFadinAnimation(activity);
                    }
                }
            }catch(Exception e){
                e.printStackTrace();
            }
        }
    });`

Issue facing now

Please help me in fixing this

irfaan008 commented 6 years ago

Is it solved? Its gonna 1 year. Issue still exists