Git Product home page Git Product logo

Comments (7)

barbeau avatar barbeau commented on May 23, 2024

Downstream OBA issue - OneBusAway/onebusaway-android#870

from embeddedsocial-android-sdk.

acrown-msft avatar acrown-msft commented on May 23, 2024

I gather from the stack trace that the call to getFragment().getString() (line 129 in /auth/GoogleAppAuthAuthenticator.java) generates an exception because the SignIn fragment which contains this object is not attached to an activity (https://stackoverflow.com/a/36745804). I get a similar stack trace by removing the SignIn fragment's mHost in a debugger.

However, I'm unable to come up with a repro without using the debugger to modify data at runtime. I'm trying to kill the app at various points in the execution but have yet to come up with anything.

@barbeau
My proposal is to add better logging information to this code block so we can identify the root cause of the issue the next time it pops up. Is there a system flag we can check to determine if the app has been killed? I'll continue trying to repro, but in the meantime, I'm just taking shots in the dark.

from embeddedsocial-android-sdk.

barbeau avatar barbeau commented on May 23, 2024

I gather from the stack trace that the call to getFragment().getString() (line 129 in /auth/GoogleAppAuthAuthenticator.java) generates an exception because the SignIn fragment which contains this object is not attached to an activity (https://stackoverflow.com/a/36745804).

I've avoided this issue in other async callbacks related to fragments by checking for isAdded() before doing something that would cause an IllegalStateException, and if it's false just returning (effectively a no-op). I've seen this in other Google code as well, including the NavigationDrawerFragment we use in OBA Android that was borrowed from a Google I/O app.

If you're simply getting string resources here, another option would be to use the Application context (which should still exist if your code is running) via Application.get().getApplicationContext().

My proposal is to add better logging information to this code block so we can identify the root cause of the issue the next time it pops up.

That would be great, but how are you going to log this? AFAIK all you get via Android Developer Console is a stack trace, so you'd need to catch the exception and then log via Google Analytics or something similar. But let me know if you have other ideas.

Is there a system flag we can check to determine if the app has been killed?

AFAIK as long as your code is running the application context should still exist

from embeddedsocial-android-sdk.

barbeau avatar barbeau commented on May 23, 2024

We finally got an unobfuscated stack trace, from a Samsung Galaxy Note8 (greatqlteue), 6144MB RAM, Android 8.0, although this is an NPE and not an IllegalStateException:

java.lang.NullPointerException: 
  at android.content.ContextWrapper.getResources (ContextWrapper.java:93)
  at android.view.ContextThemeWrapper.getResourcesInternal (ContextThemeWrapper.java:127)
  at android.view.ContextThemeWrapper.getResources (ContextThemeWrapper.java:121)
  at android.support.v4.app.Fragment.getResources (Fragment.java:678)
  at android.support.v4.app.Fragment.getString (Fragment.java:700)
  at com.microsoft.embeddedsocial.auth.GoogleAppAuthAuthenticator$1.onTokenRequestCompleted (GoogleAppAuthAuthenticator.java:129)
  at net.openid.appauth.AuthorizationService$TokenRequestTask.onPostExecute (AuthorizationService.java:308)
  at net.openid.appauth.AuthorizationService$TokenRequestTask.onPostExecute (AuthorizationService.java:238)
  at android.os.AsyncTask.finish (AsyncTask.java:695)
  at android.os.AsyncTask.-wrap1 (Unknown Source)
  at android.os.AsyncTask$InternalHandler.handleMessage (AsyncTask.java:712)
  at android.os.Handler.dispatchMessage (Handler.java:105)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6940)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

from embeddedsocial-android-sdk.

barbeau avatar barbeau commented on May 23, 2024

From a quick look at the code, it looks like this new NPE and the IllegalStateException are separate issues.

from embeddedsocial-android-sdk.

barbeau avatar barbeau commented on May 23, 2024

I opened a new issue for the above NPE at #94.

from embeddedsocial-android-sdk.

Stokesd503 avatar Stokesd503 commented on May 23, 2024

Nice I guess

from embeddedsocial-android-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.