android


Android ANR when trying to start service


I have a service which has been working perfectly for weeks, and in the last day has suddenly started having problems. I know I've added something recently which triggered this behavior but looking back through my GIT logs I can't find anything that seems obvious so I'm going to try to see if anyone can help me understand what is actually happening instead.
From a button click in a fragment I call the following method:
private void performEnterCalibrationMode(Intent intent) {
Log.d(TAG, "Creating calibration mode task.");
final CalibrationModeTask calTask = new CalibrationModeTask(CALIBRATION_MODE.ENTER_CALIBRATION_MODE);
intent.putExtra(TekCast.EXTRA_TASK, calTask);
intent.putExtra(TekCast.EXTRA_TASK_COMPLETE_CALLBACK, this);
Log.d(TAG, "Broadcasting calibration mode task intent.");
mContext.startService(intent);
Log.d(TAG, "Intent was broadcast.");
}
I see the "Intent was broadcast" message in my log, so I know I've made it that far.
The service's onCreate() method is as follows:
#Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "CommunicationService onCreate()");
// Setup the background thread and its controls
HandlerThread thread = new HandlerThread("TekDAQC Communication Service", Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
mServiceLooper = thread.getLooper();
mServiceHandler = new ServiceHandler(mServiceLooper, this);
mLocalBroadcastMgr = LocalBroadcastManager.getInstance(getApplicationContext());
// Initialize the session map
mCommSessions = new ConcurrentHashMap<String, ASCIICommunicationSession>();
}
The service's onStartCommand() method is as follows:
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
// Extract the service instruction
final String action = intent.getAction();
Log.d(TAG, "Received start command: " + action);
// Build the message parameters
Bundle extras = intent.getExtras();
if (extras == null)
extras = new Bundle();
extras.putString(TekCast.EXTRA_SERVICE_ACTION, action);
// Run each task in a background thread.
final Message msg = mServiceHandler.obtainMessage();
msg.arg1 = startId;
msg.setData(extras);
Log.d(TAG, "Sending message to background thread.");
mServiceHandler.sendMessage(msg);
return Service.START_NOT_STICKY;
}
None of the log statements from onStartCommand() or onCreate() for the service are ever called. Instead, I get the following stack trace and an ANR:
09-06 19:00:58.291: D/CalibrationSteps(2228): Creating calibration mode task.
09-06 19:00:58.291: D/CalibrationSteps(2228): Broadcasting calibration mode task intent.
09-06 19:00:58.601: I/art(2228): GcCauseBackground sticky partial concurrent mark sweep GC freed 50607(2MB) AllocSpace objects, 5(202KB) LOS objects, 5% free, 37MB/39MB, paused 9.869ms total 72.321ms
09-06 19:00:59.361: I/art(2228): GcCauseBackground sticky partial concurrent mark sweep GC freed 17890(841KB) AllocSpace objects, 0(0B) LOS objects, 5% free, 39MB/41MB, paused 11.853ms total 19.861ms
09-06 19:00:59.371: D/CalibrationSteps(2228): Intent was broadcast.
09-06 19:00:59.581: I/System.out(2228): Discovery timed out.
09-06 19:00:59.581: I/System.out(2228): Closing socket...
09-06 19:01:19.431: I/art(2228): Thread[5,tid=2234,WaitingInMainSignalCatcherLoop,Thread*=0x4749b3e8,peer=0x65551c10,"Signal Catcher"]: reacting to signal 3
09-06 19:01:19.511: I/art(2228): Wrote stack traces to '/data/anr/traces.txt'
I have added strict mode logging in my application's 'onCreate()' method, but it does not report anything:
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
And of course I have my service declared in my manifest (it has been working until today).
So ultimately my question is, what would cause an intent to send successfully but have an ANR reported rather than starting the service? Why is StrictMode not detecting it?
REQUESTED ADDITIONAL INFORMATION
The intent is passed to the performEnterCalibrationMode(Intent) method by the following code:
final Intent intent = new Intent(mContext, CommunicationService.class);
intent.setAction(ServiceAction.EXECUTE_TASK.toString());
UPDATE
It turns out the service is being started prior to this (I am able to send commands to it to connect). However, when I send this command after connecting (a second or two), thats when I get the ANR.

Related Links

Audio file uploaded from android not working in ios
How to recreate all fragments in ViewPager:
Ecommerce Android is not shown in analytics
How to swipe and switch between two images?
Android Mapview show white tiles without any map
How can i save audio from speech recognition API?
Navigation tabs with fragments to which to add another fragment
Get the category of any app programetically in Android?
PhoneGap for Android - Connect to Database
Passing data from a Service
Building cocos2d-x android project failed: Unknown EABI object attribute 44
Add a layout in a view
Android Programming ViewPager from a GridView
Monitoring wifi state change since boot time in Android
Writing arbitrary metadata to EXIF in Android
Screen Size of VideoView is changing When playing video in VideoView Android

Categories

HOME
batch-file
asp.net-web-api
scikit-learn
facebook-oauth
paraview
eslint
string
telegram
angular-formly
google-cloud-functions
telegram-bot
alamofire
jxl
xcodebuild
jsonpath
stellar.js
google-data-studio
xmonad
bourbon
interpreter
gpio
intersystems-cache
comparable
papaparse
openwhisk
sharding
baidu-map
least-squares
batching
navigator
salesforce-communities
jpad
flatmap
portforwarding
install.packages
flask-restful
cnc
yii2-api
rserve
zenhub
compiler-design
oracleclient
backbone-collections
headless
monkey
universal-analytics
renaming
pocketsphinx-android
juice-ui
testrail
chromium-os
custom-lists
jboss-tools
appscale
stream-processing
turbo-prolog
directdraw
rubaxa-sortable
branch-and-bound
jsvc
mirror
avahi
public-html
openbabel
qtwebengine
universal-image-loader
nsmenu
eclipse-kepler
gtm-oauth2
route-provider
actiondispatch
stacky
twisted.web
wcf-configuration
lambdaj
inkcanvas
jdb
usertype
flex-mobile
catransform3d
automationelement
cgbitmapcontextcreate
http-daemon
squishit
feasibility
pbcopy
great-circle

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App