-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
NPE while invoking tinylog from an AIDL remote interface callback #131
Comments
@danielwilson1702 Would you be able to provide an example project? Which tinylog version and Android version are you using? |
I've tried it with a super simple AIDL / Service sample and can't repro. So it must be something relatively specific. I will try and create a very simple project with nothing but the Service I am using. Versions are:
|
Ok sorry this has taken a while! I have a small sample now located here showing the issue. Now unfortunately you won't be able to run it because the only Service I can find that is causing the issue is the one I am using which is from the Poynt SDK. Poynt are a POS company who ask you to set up an emulator (instructions) which requires a developer account in order to talk to their Services / backend. I am thinking perhaps even without running the code it can give you some insight. The app simply connects to their "Business" Service to gather the Business details from the device / Poynt account. I have also figured out perhaps the biggest clue, if I log in onResume, the Service callback call to log does not crash the app. If I do not log in onResume and the first call to log is the one in the Service callback, the app crashes. Let me know if that makes sense! So I believe right now the solution is just to log something in a regular platform lifecycle call back such as App / Activity / Fragment onCreate() to give the library a chance to initialize itself correctly, and allow me to log anywhere. |
The problem seems to be that Poynt creates threads with @danielwilson1702 Could you test the attached snapshots and provide the logger output? |
Brilliant ok thanks for looking in to it. It is reassuring to know that Poynt are doing unusual things with their SDK and it's not the first time I've said that 😄 Using the snapshot jar seems to produce a stack overflow exception:
Full logs (probably too much info here but you get the gist!) It doesn't seem to get in to this if statement:
|
It is always a bit tricky to develop something that you cannot test by yourself :-D I have fixed the endless recursion. @danielwilson1702 Could you test again? |
I'm sure it is! Ok I tested it and it looks like it's working perfectly now:
I will close this bug and be careful around any crazy Poynt functions until you roll it out. Thanks a lot 🎉 👌 |
Then I can merge my change into the v2.1 branch. @danielwilson1702 Thank you for testing! |
This closed issue has been locked automatically. However, please feel free to file a new issue. |
My code is throwing an exception for this constructor:
I believe
Thread.currentThread().getContextClassLoader();
is returning null in certain instances in my app. I don't understand enough about Java or AIDLs to see what's happening here, but suffice it to say calls to log functions (such asLogger.trace()
) are crashing when they are invoked from very specific interface call backs in my app which use AIDL and are on a background thread. Running Logger.trace on the main thread from within the interface callback fixes the issue, but I am worried now there could be places in my code I don't make this fix, and also that I might be introducing other subtle issues I don't know about, like this one.This is probably an Android only problem, but would love to know what the cause is and how I might mitigate it. It's super difficult for me to try and make a reproducible sample because I am seeing the error in an SDK dependency which uses TinyLog
The text was updated successfully, but these errors were encountered: