Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANRWatchDog ANRListener not working in debug mode #4

Open
Adeel984 opened this issue Jul 29, 2020 · 0 comments
Open

ANRWatchDog ANRListener not working in debug mode #4

Adeel984 opened this issue Jul 29, 2020 · 0 comments

Comments

@Adeel984
Copy link

Adeel984 commented Jul 29, 2020

I'm trying to use this repo to get ANR errors and log it into Crashlytics but unfortunately while debugging niether call back for SetANRListener is working nor SetANRInterceptor.
Here is how i'm using it.

in my MainActivity

new ANRWatchDog(1000).SetANRListener(new MyANRListener())
                .SetIgnoreDebugger(true)
                .SetANRInterceptor(new MyANRInterceptor())
               // .SetReportMainThreadOnly()
                .Start();

Classes for listeners

public class MyANRListener : ANRWatchDog.IANRListener
	{
		public void OnAppNotResponding(ANRError error)
		{
            //Handle the ANR error. log it to Crashlytics:
            try
            {
                Crashlytics.Crashlytics.LogException(error);
            } catch(Exception ex)
            {

            }
		}
    }
public class MyANRInterceptor : IANRInterceptor
    {
        string TAG = "ANR: ";
        public long Intercept(long duration)
        {
            long ret = 5000 - duration;
            if (ret > 0)
            {
                Log.Warn(TAG, $"Intercepted ANR that is too short ({duration} ms), postponing for {ret} ms");
            }
            return ret;
        }
        public MyANRInterceptor()
        {
        }
    }

I'm trying with Thread.Sleep(10000); i'm getting ANR but none of your listener are getting hit while debugging.

awmoeder pushed a commit to awmoeder/Xamarin.ANRWatchDog that referenced this issue Sep 8, 2023
tbambuch added a commit to tbambuch/Xamarin.ANRWatchDog.netcore that referenced this issue Oct 4, 2023
bug fix issue nwestfall#4. SetIgnoreDebugger(true) not working in Xamarin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant