saravanarajan / acra

Automatically exported from code.google.com/p/acra
0 stars 0 forks source link

putCustomData won't work in remote service #40

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. startService to start service in remote process
2. In onStartCommand of the service, do

ErrorReporter.getInstance().putCustomData("info","hello");

3. Crush application by doing

 String crashString = null;
 Log.e(TAG,crashString.toString());
----
I can't see "info=hello" in "custom" cell, instead that is blank.

I know calling putCustomData in main Activity (same process that ACRA.init 
called) works as documented.
----
ACRA 3.1.1 on OS 2.1.1
----
I hope putCustomData can be called from service since my service has the 
information worth posting.

Original issue reported on code.google.com by DailyTi...@gmail.com on 13 Mar 2011 at 2:49

GoogleCodeExporter commented 9 years ago
I've not tested ACRA with services yet... I'll start.

Anyway, if the report is sent, there should be no big deal with handling custom 
data.

Original comment by kevin.gaudin on 13 Mar 2011 at 7:31

GoogleCodeExporter commented 9 years ago
Just implemented a simple test based on 
http://developer.android.com/intl/fr/resources/samples/ApiDemos/src/com/example/
android/apis/app/LocalService.html

As I am building for Android 1.5, I used onStart() instead of onStartCommand(), 
and everything went fine: custom data is correctly received in the spreadsheet.

Next test will be with onStartCommand(), running on 2.1.1 avd.

Original comment by kevin.gaudin on 13 Mar 2011 at 10:26

GoogleCodeExporter commented 9 years ago
New test done on Android 2.1.1 with ACRA 3.1.1, using onStartCommand:

    @Override
    public int onStartCommand(Intent intent, int flags ,int startId) {
        Log.i("LocalService", "Received start id " + startId + ": " + intent);
        ErrorReporter.getInstance().putCustomData("Hello", "World!");
        String nul = null;
        nul.toString();
        return START_NOT_STICKY;
    }

Report looks ok, with "Hello=World!" in the custom column.

Are you sure it is not just hidden due to the default bottom left text 
alignment ?

https://docs.google.com/uc?id=0B9J0DEDzWLEjMGU2YjBkMDItMzA5Zi00YzZiLWI0MDYtM2M5Y
mJlMjZhZWVk&export=download&hl=fr&align.png

Original comment by kevin.gaudin on 13 Mar 2011 at 10:50

GoogleCodeExporter commented 9 years ago
Hi Kevin,

Thank you for verifying the issue so quickly. I wonder you tried with service 
without

process=":remote" 

which runs service in same process. In this case it worked. (I verified today.) 
But running service in separate process by giving

process=":any_string_you_like"

ends up with blank "custom" data. Please try just adding above key word to 
service tag in AndroidManifest.xml.

I hope you will see same issue that I'm having.

Original comment by DailyTi...@gmail.com on 13 Mar 2011 at 10:59

GoogleCodeExporter commented 9 years ago
My first test was without specifying any android:process value.

I just tested with
<service android:name="LocalService" android:process=":test_process"></service>
and it still works as expected (custom data is sent).

What is your setting for android:process in the <application> tag?

Original comment by kevin.gaudin on 13 Mar 2011 at 11:12

GoogleCodeExporter commented 9 years ago
Hi Kevin,

I verified this issue again and found this.

If service is running in separate process and and call putCustomData in that 
process, and crushes in that process it WORKS as expected.

But if service is running in separate process and and call putCustomData in 
that process, and crushes in ANOTHER process (in my case main Activity) it DOES 
NOT work as expected.

Could you check it again?

Original comment by DailyTi...@gmail.com on 13 Mar 2011 at 11:28

GoogleCodeExporter commented 9 years ago
Ok, I reproduced this. And it kind of makes sense as we are now using 2 
different processes... the ErrorReporter is not a singleton anymore.

I have to think about this.

Original comment by kevin.gaudin on 13 Mar 2011 at 11:43

GoogleCodeExporter commented 9 years ago
I can't see a simple way to work this around... I think we would need to make 
the remote service send a message to the main process to handle the exception 
(and any custom data) instead of handling it in the service process.
http://developer.android.com/intl/fr/guide/topics/fundamentals/bound-services.ht
ml#Messenger

It may be possible to provide some tooling to ease this but it requires too 
much effort to be done now. I have to plan this after the release of v3.2.

If you want to work on this and contribute back your findings, you are welcome 
;-)

Original comment by kevin.gaudin on 15 Mar 2011 at 12:34

GoogleCodeExporter commented 9 years ago
Hi Kevin,

Thank you for taking time for this issue.
I understood the situation. I hope ACRA will support this sometime in future.

Original comment by kato.dai...@gmail.com on 15 Mar 2011 at 8:06

GoogleCodeExporter commented 9 years ago

Original comment by kevin.gaudin on 25 Nov 2011 at 11:20