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

Only the original thread that created a view hierarchy can touch its views. #1076

Closed
Eqbalazar opened this issue Dec 18, 2017 · 14 comments
Closed
Assignees
Milestone

Comments

@Eqbalazar
Copy link

Eqbalazar commented Dec 18, 2017

I am getting error after login , upgrade ADAL version from 1.12.0 to 1.13.2

12-18 09:54:24.153 9842-9930/? E/AndroidRuntime: FATAL EXCEPTION: AcquireTokenRequestHandlerThread
                                                 Process: com.companyname.appname, PID: 9842
                                                 android.view.ViewRootImpl$CalledFromWrongThreadException: 
												 Only the original thread that created a view hierarchy can touch its views.
                                                     at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8197)
                                                     at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1268)
                                                     at android.view.View.requestLayout(View.java:20084)
                                                     at android.view.View.requestLayout(View.java:20084)
                                                     at android.view.View.requestLayout(View.java:20084)
                                                     at android.view.View.requestLayout(View.java:20084)
                                                     at android.view.View.requestLayout(View.java:20084)
                                                     at android.view.View.requestLayout(View.java:20084)
                                                     at android.support.v4.widget.DrawerLayout.requestLayout(Unknown Source)
                                                     at android.view.View.requestLayout(View.java:20084)
                                                     at android.view.View.requestLayout(View.java:20084)
                                                     at android.support.v7.widget.av.requestLayout(Unknown Source)
                                                     at android.view.View.requestLayout(View.java:20084)
                                                     at android.view.View.requestLayout(View.java:20084)
                                                     at android.view.View.requestLayout(View.java:20084)
                                                     at android.widget.TextView.checkForRelayout(TextView.java:8382)
                                                     at android.widget.TextView.setText(TextView.java:5000)
                                                     at android.widget.TextView.setText(TextView.java:4827)
                                                     at android.widget.TextView.setText(TextView.java:4802)
                                                     at com.companyname.appname.MainActivity.A(Unknown Source)
                                                     at com.companyname.appname.MainActivity.d(Unknown Source)
                                                     at com.companyname.appname.MainActivity$6.a(Unknown Source)
                                                     at com.companyname.appname.MainActivity$6.onSuccess(Unknown Source)
                                                     at com.microsoft.aad.adal.AcquireTokenRequest$CallbackHandler$2.run(Unknown Source)
                                                     at android.os.Handler.handleCallback(Handler.java:739)
                                                     at android.os.Handler.dispatchMessage(Handler.java:95)
                                                     at android.os.Looper.loop(Looper.java:158)
                                                     at android.os.HandlerThread.run(HandlerThread.java:61)
12-18 09:54:24.158 2788-3090/? W/ActivityManager:   Force finishing activity com.companyname.appname/.MainActivity
@nazukj nazukj added this to the January2018 milestone Dec 19, 2017
@nazukj nazukj removed this from the January2018 milestone Dec 19, 2017
@heidijinxujia
Copy link
Member

Hi @Eqbalazar thank you for reporting this issue. This is not clear which call did you made and get this error. The stacktrace here only shows CalledFromWrongThreadException is thrown which is from Android. Could you attach your code where the adal auth call is made? Is it from main thread or background thread? Please attach the complete adal logs as well.

@Eqbalazar
Copy link
Author

Eqbalazar commented Dec 19, 2017

Hi @heidijinxujia ,
It is in Background Service :

FileTokenCache _FileTokenCacheStore = new FileTokenCache(getApplicationContext(),
"fileCacheToken.dat");
AuthenticationContext m = new AuthenticationContext(getApplicationContext(),
Constants.AUTHORITY_URL, _FileTokenCacheStore);

I have to do refresh token in back ground in order to prevent loging again by users.

@heidijinxujia
Copy link
Member

heidijinxujia commented Dec 20, 2017

Thank you for the quick reply. @Eqbalazar Which adal API you are calling when trying to refresh the token?

@Eqbalazar
Copy link
Author

Hi @heidijinxujia ,
ADAL Version 1.13.2

@heidijinxujia
Copy link
Member

Hi @Eqbalazar The ADAL API is referring to the function you called in your client app code, not the version number. For exception, are you making an acquireTokenCall? If so, which function are you calling? Thanks.

@heidijinxujia
Copy link
Member

Close the issue because we have not got the reply from customer for more than two weeks. Please feel free to reopen it if you got further question. Thanks.

@MoBo
Copy link

MoBo commented Jan 17, 2018

I have the same issue. AuthenticationCallback seem to invoked on a background thread in Version 1.13.3. In Version 1.3.0 the callback was executed on the main thread. Is this the expected behaviour in the new version?

@iambmelt
Copy link
Member

Hello @MoBo @Eqbalazar -- From my testing, I can confirm this as an unintended change that occurred between versions 1.13.1 and 1.13.2. I will consult with my team and see that a test case is added for future releases.

Reopening this issue, as it's now confirmed.

@iambmelt iambmelt reopened this Jan 17, 2018
@iambmelt
Copy link
Member

@nazukj Just putting this on your radar: we can follow-up regarding next steps, milestone, etc.

/cc @heidijinxujia @addev-ashish @piqiums

@iambmelt iambmelt added bug and removed Investigate labels Jan 17, 2018
@piqiums
Copy link
Contributor

piqiums commented Jan 17, 2018

@Eqbalazar, please look at

public CallbackHandler(Handler ref, AuthenticationCallback<AuthenticationResult> callbackExt) {

In the 'AuthenticationCallback callbackExt', in the method 'onError' & "onSuccess", please update UI on UI Thread via "runOnUiThread". Please don't suppose these 2 callback methods would definitely be called on UI thread. https://developer.android.com/reference/android/app/Activity.html#runOnUiThread(java.lang.Runnable)

The "AcquireTokenRequest" should not run on UI thread since it's not UI related, and we moved it to a non-UI thread to keep the UI thread responsive to the user input.

@piqiums
Copy link
Contributor

piqiums commented Jan 17, 2018

@Eqbalazar , is your app released or still in development? thanks

@Eqbalazar
Copy link
Author

Hi @piqiums , I tested in Development , I am using 1.13.1 on release .

@nazukj nazukj added this to the February2018 milestone Jan 18, 2018
heidijinxujia pushed a commit that referenced this issue Jan 19, 2018
Updated documentation to remove warnings around AS3/J8 and to include a Known Issue for #1076
@nazukj
Copy link
Contributor

nazukj commented Jan 31, 2018

@Eqbalazar, is this working for you with Ping's suggestion?

@Eqbalazar
Copy link
Author

Eqbalazar commented Jan 31, 2018 via email

@piqiums piqiums closed this as completed Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants