On Jul 30, 2011, at 1:53 AM, Tim Kelly wrote:
> Ok, I got it coded and it starts, but crashes.  It looks like it calls 
> [BroadcastReceiver]
>  
> But, the emulator says it stopped.  I tried to put some logging in to see 
> where it dies.  However, it  never gets there. It seems to crash before.  Is 
> this an issue with MonDroid?  I have the same application written in Java and 
> it starts just fine.  Not sure why the MonoDroid crashes.  In the 
> [BroadcastReceiver] I commented out the service start and it still crashes.  
> I coded a simple hello world app and it too crashes, anyone have it working 
> on power up?

I CAN HAZ CONJECTURE?

Seriously, conjecture is all I've got!

Behold, a working sample!

        http://www.jprl.com/tmp/ScratchStartOnBoot.zip

Behold, `adb logcat` [0]! 

You'll have to take my word for it that I don't see any "Process 
scratchstartonboot.scratchstartonboot has died" messages. (OK, you could 
install the .apk in the above .zip...).

The question is...why does my package work, and yours doesn't?

Logging!

Seriously, that's my conjecture. If I remove the Log.Info() messages, I get 
[1], where if you look closely enough you'll see that the 
scratchstartonboot.scratchstartonboot process runs, then is sent signal 3 
(SIGQUIT), and then later signal 9 (SIGKILL)?

My further conjecture as to why the process is being killed is 
http://developer.android.com/reference/android/content/BroadcastReceiver.html:

Once you return from onReceive(), the BroadcastReceiver is no longer active, 
and its hosting process is only as important as any other application 
components that are running in it. This is especially important because if that 
process was only hosting the BroadcastReceiver (a common case for applications 
that the user has never or not recently interacted with), then upon returning 
from onReceive() the system will consider its process to be empty and 
aggressively kill it so that resources are available for other more important 
processes.

I'd call SIGKILL "aggressively kill[ing] it."

My backup conjecture (also verified) is that, even without all the extra 
logging that [0] has, if I change ReceiveBoot.OnReceive():

        -                               
context.ApplicationContext.StartService(new Intent(context, 
typeof(LocationService)));
        +                               context.StartService(new 
Intent(context, typeof(LocationService)));

That is, if I do _not_ use `context.ApplicationContext`, but instead use 
`context`, then the StartService() call seems to be effective, and the process 
isn't killed.

Thus, I would suggest that you try using `context.StartService()` instead of 
`context.ApplicationContext.StartService()` to start your Service. If that 
fails, add more logging. :-)

 - Jon

[0]
I/ActivityManager(   58): Start proc scratchstartonboot.scratchstartonboot for 
broadcast scratchstartonboot.scratchstartonboot/scratchstartonboot.ReceiveBoot: 
pid=192 uid=10037 gids={3003, 1015}
I/ActivityThread(  179): Pub call_log: 
com.android.providers.contacts.CallLogProvider
I/ActivityThread(  179): Pub user_dictionary: 
com.android.providers.userdictionary.UserDictionaryProvider
I/ActivityThread(  192): Pub 
scratchstartonboot.scratchstartonboot.__mono_init__: mono.MonoRuntimeProvider
D/dalvikvm(  192): Trying to load lib 
/data/data/scratchstartonboot.scratchstartonboot/lib/libmonodroid.so 0x40514f80
D/dalvikvm(  192): Added shared lib 
/data/data/scratchstartonboot.scratchstartonboot/lib/libmonodroid.so 0x40514f80
I/SearchManagerService(   58): Building list of searchable activities
D/dalvikvm(  192): GC_CONCURRENT freed 380K, 53% free 2677K/5639K, external 
716K/1038K, paused 5ms+4ms
D/dalvikvm(  192): GC_CONCURRENT freed 385K, 53% free 2772K/5831K, external 
716K/1038K, paused 5ms+4ms
D/dalvikvm(  192): GC_CONCURRENT freed 402K, 52% free 2916K/5959K, external 
716K/1038K, paused 5ms+4ms
D/*jonp*  (  192): MyApp.OnCreate
I/*jonp*  (  192): ReceiveBoot.OnReceive
I/*jonp*  (  192): ReceiveBoot.OnReceive: launching LocationService...
D/*jonp*  (  192): LocationManager.#ctor
D/*jonp*  (  192): LocationManager.OnCreate
I/LocationService(  192): Received start id 1: Intent { 
cmp=scratchstartonboot.scratchstartonboot/scratchstartonboot.LocationService }
I/ActivityManager(   58): Start proc android.process.media for broadcast 
com.android.providers.downloads/.DownloadReceiver: pid=205 uid=10000 
gids={1015, 1006, 2001, 3003}

[1]
I/ActivityManager(   60): Start proc scratchstartonboot.scratchstartonboot for 
broadcast scratchstartonboot.scratchstartonboot/scratchstartonboot.ReceiveBoot: 
pid=206 uid=10037 gids={3003, 1015}
D/SntpClient(   60): request time failed: java.net.SocketException: Address 
family not supported by protocol
D/dalvikvm(   32): GC_EXPLICIT freed 10K, 53% free 2538K/5379K, external 
1625K/2137K, paused 219ms
D/dalvikvm(   60): GC_CONCURRENT freed 722K, 45% free 4148K/7495K, external 
4373K/5573K, paused 6ms+35ms
D/dalvikvm(   32): GC_EXPLICIT freed <1K, 53% free 2538K/5379K, external 
1625K/2137K, paused 274ms
D/dalvikvm(   32): GC_EXPLICIT freed <1K, 53% free 2538K/5379K, external 
1625K/2137K, paused 168ms
D/dalvikvm(  126): GC_EXTERNAL_ALLOC freed 64K, 51% free 2780K/5639K, external 
4217K/4261K, paused 149ms
I/ActivityThread(  180): Pub call_log: 
com.android.providers.contacts.CallLogProvider
I/ActivityThread(  180): Pub user_dictionary: 
com.android.providers.userdictionary.UserDictionaryProvider
I/ActivityThread(  206): Pub 
scratchstartonboot.scratchstartonboot.__mono_init__: mono.MonoRuntimeProvider
D/dalvikvm(  206): Trying to load lib 
/data/data/scratchstartonboot.scratchstartonboot/lib/libmonodroid.so 0x40515280
D/dalvikvm(  206): Added shared lib 
/data/data/scratchstartonboot.scratchstartonboot/lib/libmonodroid.so 0x40515280
D/dalvikvm(  126): GC_EXTERNAL_ALLOC freed 28K, 51% free 2798K/5639K, external 
5345K/5346K, paused 113ms
I/SurfaceFlinger(   60): Boot is finished (23934 ms)
I/ARMAssembler(   60): generated scanline__00000177:03010104_00000002_00000000 
[ 44 ipp] (66 ins) at [0x44531290:0x44531398] in 920000 ns
I/ARMAssembler(   60): generated scanline__00000177:03515104_00000001_00000000 
[ 73 ipp] (95 ins) at [0x445313a0:0x4453151c] in 1269000 ns
D/dalvikvm(  126): GC_EXPLICIT freed 53K, 51% free 2764K/5639K, external 
5417K/6692K, paused 225ms
D/dalvikvm(   60): GC_EXPLICIT freed 132K, 45% free 4136K/7495K, external 
4373K/5573K, paused 148ms
D/dalvikvm(  206): GC_CONCURRENT freed 366K, 54% free 2635K/5639K, external 
1625K/2137K, paused 4ms+4ms
D/dalvikvm(  206): GC_CONCURRENT freed 441K, 53% free 2810K/5895K, external 
1625K/2137K, paused 5ms+4ms
D/dalvikvm(  206): GC_CONCURRENT freed 482K, 52% free 2942K/6087K, external 
1625K/2137K, paused 5ms+4ms
D/*jonp*  (  206): MyApp.OnCreate
W/ActivityManager(   60): Timeout of broadcast BroadcastRecord{406f7e98 
android.intent.action.BOOT_COMPLETED} - 
receiver=android.os.BinderProxy@405ffe08, started 10004ms ago
W/ActivityManager(   60): Receiver during timeout: ResolveInfo{406f7cc0 
scratchstartonboot.ReceiveBoot p=0 o=0 m=0x108000}
I/ActivityManager(   60): Start proc android.process.media for broadcast 
com.android.providers.downloads/.DownloadReceiver: pid=218 uid=10000 
gids={1015, 1006, 2001, 3003}
I/RecoverySystem(   60): No recovery log file
I/Process (   60): Sending signal. PID: 206 SIG: 3
I/dalvikvm(  206): threadid=4: reacting to signal 3
I/Process (   60): Sending signal. PID: 60 SIG: 3
I/dalvikvm(   60): threadid=4: reacting to signal 3
I/dalvikvm(  206): Wrote stack traces to '/data/anr/traces.txt'
I/Process (   60): Sending signal. PID: 117 SIG: 3
I/dalvikvm(  117): threadid=4: reacting to signal 3
I/dalvikvm(   60): Wrote stack traces to '/data/anr/traces.txt'
I/Process (   60): Sending signal. PID: 119 SIG: 3
I/dalvikvm(  119): threadid=4: reacting to signal 3
I/dalvikvm(  119): Wrote stack traces to '/data/anr/traces.txt'
I/dalvikvm(  117): Wrote stack traces to '/data/anr/traces.txt'
I/ActivityThread(  218): Pub media: com.android.providers.media.MediaProvider
V/MediaProvider(  218): Attached volume: internal
I/ActivityThread(  218): Pub downloads: 
com.android.providers.downloads.DownloadProvider
I/ActivityThread(  218): Pub drm: com.android.providers.drm.DrmProvider
D/dalvikvm(   60): GC_EXPLICIT freed 243K, 44% free 4233K/7495K, external 
4373K/5573K, paused 87ms
I/ActivityManager(   60): Start proc com.android.mms for broadcast 
com.android.mms/.transaction.MmsSystemEventReceiver: pid=229 uid=10015 
gids={3003, 1015}
I/Process (   60): Sending signal. PID: 180 SIG: 3
I/dalvikvm(  180): threadid=4: reacting to signal 3
I/ActivityThread(  229): Pub com.android.mms.SuggestionsProvider: 
com.android.mms.SuggestionsProvider
E/ActivityManager(   60): Start proc com.android.mms for broadcast 
com.android.mms/.transaction.MmsSystemEventReceiver: pid=229 uid=10015 
gids={3003, 1015}Load: 3.33 / 0.81 / 0.27
E/ActivityManager(   60): CPU usage from 7021ms to 0ms ago:
E/ActivityManager(   60):   69% 206/scratchstartonboot.scratchstartonboot: 62% 
user + 6.7% kernel / faults: 2195 minor 19 major
E/ActivityManager(   60):   12% 126/com.android.launcher: 6.9% user + 5.6% 
kernel / faults: 635 minor 2 major
E/ActivityManager(   60):   10% 60/system_server: 3.8% user + 6.9% kernel / 
faults: 162 minor
E/ActivityManager(   60):   2.5% 117/com.android.phone: 0% user + 2.5% kernel
E/ActivityManager(   60):   1.4% 183/zygote: 0.1% user + 1.2% kernel / faults: 
1 minor
E/ActivityManager(   60):   1.2% 159/com.android.settings: 0.2% user + 0.9% 
kernel
E/ActivityManager(   60):   1.2% 180/android.process.acore: 0.1% user + 1.1% 
kernel / faults: 1 minor
E/ActivityManager(   60):   0.2% 40/adbd: 0% user + 0.2% kernel
E/ActivityManager(   60):   0.1% 32/zygote: 0.1% user + 0% kernel / faults: 8 
minor
E/ActivityManager(   60):   0.1% 82/logcat: 0% user + 0.1% kernel
E/ActivityManager(   60): 100% TOTAL: 74% user + 25% kernel
E/ActivityManager(   60): CPU usage from 1771ms to 2486ms later:
E/ActivityManager(   60):   18% 60/system_server: 7.1% user + 11% kernel / 
faults: 30 minor
E/ActivityManager(   60):     8.5% 73/ActivityManager: 5.7% user + 2.8% kernel
E/ActivityManager(   60):     2.8% 60/system_server: 2.8% user + 0% kernel
E/ActivityManager(   60):    +0% 233/Error dump: sys: 0% user + 0% kernel
E/ActivityManager(   60):   11% 218/android.process.media: 2.8% user + 8.6% 
kernel / faults: 190 minor
E/ActivityManager(   60):     7.2% 224/Binder Thread #: 1.4% user + 5.7% kernel
E/ActivityManager(   60):     2.8% 218/d.process.media: 1.4% user + 1.4% kernel
E/ActivityManager(   60):     1.4% 225/Binder Thread #: 0% user + 1.4% kernel
E/ActivityManager(   60):   1.8% 206/scratchstartonboot.scratchstartonboot: 0% 
user + 1.8% kernel
E/ActivityManager(   60):     1.8% 207/HeapWorker: 0% user + 1.8% kernel
E/ActivityManager(   60):   0.7% 32/zygote: 0% user + 0.7% kernel / faults: 16 
minor
E/ActivityManager(   60):   1.4% 40/adbd: 0% user + 1.4% kernel
E/ActivityManager(   60):   0.9% 180/android.process.acore: 0% user + 0.9% 
kernel
E/ActivityManager(   60):  +0% 229/com.android.mms: 0% user + 0% kernel
E/ActivityManager(   60): 100% TOTAL: 18% user + 81% kernel
I/Process (   60): Sending signal. PID: 206 SIG: 9
D/dalvikvm(   60): GREF has increased to 301
I/ActivityManager(   60): Start proc com.android.email for broadcast 
com.android.email/.service.EmailBroadcastReceiver: pid=251 uid=10028 
gids={3003, 1015}
I/dalvikvm(  180): Wrote stack traces to '/data/anr/traces.txt'
I/ActivityThread(  251): Pub com.android.email.provider: 
com.android.email.provider.EmailProvider
I/ActivityThread(  251): Pub com.android.email.attachmentprovider: 
com.android.email.provider.AttachmentProvider
I/ActivityThread(  251): Pub com.android.exchange.provider: 
com.android.exchange.provider.ExchangeProvider
I/ActivityManager(   60): Start proc com.android.quicksearchbox for broadcast 
com.android.quicksearchbox/.SearchWidgetProvider: pid=263 uid=10002 gids={3003}
D/EAS SyncManager(  251): !!! EAS SyncManager, onCreate
I/ActivityThread(  263): Pub com.android.quicksearchbox.google: 
com.android.quicksearchbox.google.GoogleSuggestionProvider
I/ActivityThread(  263): Pub com.android.quicksearchbox.shortcuts: 
com.android.quicksearchbox.ShortcutsProvider
D/AlarmManagerService(   60): Kernel timezone updated to 240 minutes west of GMT
D/SystemClock(  117): Setting time of day to sec=1313029990
W/SystemClock(  117): Unable to set rtc to 1313029990: Invalid argument
I/ActivityManager(   60): Start proc com.android.music for broadcast 
com.android.music/.MediaAppWidgetProvider: pid=274 uid=10005 gids={3003, 1015}
D/Eas Debug(  251): Logging: 
I/ActivityManager(   60): Start proc com.android.protips for broadcast 
com.android.protips/.ProtipWidget: pid=283 uid=10024 gids={}
D/EAS SyncManager(  251): !!! EAS SyncManager, onDestroy
I/ActivityManager(   60): Process scratchstartonboot.scratchstartonboot (pid 
206) has died.

_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to