Ektorp Android - CouchbaseViewListAdapter followChanges=true blocks other AsyncTasks #88

Open
schmidek opened this Issue Aug 24, 2012 · 5 comments

Comments

Projects
None yet
4 participants

Starting with Honeycomb and greater and targetsdk set to 13 or greater, AsyncTasks are run on the serial executor by default.
This means when CouchbaseViewListAdapter followChanges=true it blocks other AsyncTasks from being run.

AsyncTasks should not be used for long running tasks, discussion here https://groups.google.com/forum/?fromgroups=#!topic/android-developers/8M0RTFfO7-M

Contributor

mschoch commented Aug 24, 2012

This is a really annoying change in the Android SDK.

Clearly ChangesFeedAsyncTask has to change to a different model because these are always intended to be long-running. I'm not sure pooling makes sense for them, so using its own new thread is probably fine. We still have to rip out the useful parts of AsyncTask that can deliver messages to the main thread when changes arrive on the feed, as people will often want to interact with the UI at that point.

The next question is should EktorpAsyncTask be allowed to continue to exist for things that are short-running? It seems like it might still work OK for these cases, but I'm not certain.

tleyden commented Jun 11, 2013

@helun Hi, I'm the new maintainer of TouchDB-Android (now renamed to Couchbase-Lite), and I want to come up for a fix for this issue. As Marty mentioned, the ChangesFeedAsyncTask will need to change to a different model due to the new way that AsyncTasks work.

I want to do this in such a way that it will get merged back into Ektorp, so I wanted to get your opinion on how you'd like to see this implemented. Also, are you aware of any forks that have tried to address this issue?

@tleyden tleyden pushed a commit to couchbaselabs/Ektorp that referenced this issue Jun 12, 2013

Traun Leyden Workaround attempt for issue #88 - use AsyncTask.THREAD_POOL_EXECUTOR…
… for long running tasks so that other async tasks can be used in parallel.
a06110d

@tleyden tleyden pushed a commit to couchbaselabs/Ektorp that referenced this issue Jun 12, 2013

Traun Leyden Workaround for issue #88 - use AsyncTask.THREAD_POOL_EXECUTOR for lon…
…g running tasks so that other async tasks can be used in parallel.

Conflicts:
	org.ektorp.android/src/main/java/org/ektorp/android/util/CouchbaseViewListAdapter.java
b60f10b

@tleyden tleyden pushed a commit to couchbaselabs/Ektorp that referenced this issue Jun 13, 2013

Traun Leyden Follow up commit for workaround attempt for issue #88 - use an earlie…
…r version of the android.jar artifact which still supports the AyncTask.THREAD_POOL_EXECUTOR
c0e570a

@tleyden tleyden pushed a commit to couchbaselabs/Ektorp that referenced this issue Jun 13, 2013

Traun Leyden Follow up commit for workaround attempt for issue #88 - use an earlie…
…r version of the android.jar artifact which still supports the AyncTask.THREAD_POOL_EXECUTOR
af6dda4

@helun helun added a commit that referenced this issue Jun 13, 2013

@helun helun Merge pull request #119 from couchbaselabs/master
Workaround for Issue #88
611b770

can we open further discussion now? It seems that couchbase-lite-android is now being said to only work on Android 3.0 and later. I don't understand, as it seems that there are three levels of capability:

  1. Prior to Android 1.6 it was ONE thread
  2. Android 1.6 to 2.99 (before 3.0) it was FIVE threads
  3. Android 3.0 to current - default of ONE thread, but easily works with 10 threads if you specify the THREAD_POOL_EXECUTOR parameters

So why can't Android 2.2 and 2.3 be supported by CBLite?

@targetapi(Build.VERSION_CODES.HONEYCOMB) // API 11
void startMyTask(AsyncTask asyncTask) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
else
asyncTask.execute(params);
}

reference: http://stackoverflow.com/questions/4068984/running-multiple-asynctasks-at-the-same-time-not-possible

tleyden commented Sep 3, 2013

@RoundSparrow good point, I should have taken that approach in my fix. Would you be able to submit a pull request to @helun for this?

@beilharz beilharz added a commit to beilharz/Ektorp that referenced this issue Oct 6, 2013

@beilharz beilharz Update CouchbaseViewListAdapter.java to work on API Level < 11
As discussed in issue #88 at helun/Ektorp
096ed0a

@beilharz beilharz added a commit to beilharz/Ektorp that referenced this issue Oct 11, 2013

@beilharz beilharz + Jossekin Beilharz Update CouchbaseViewListAdapter.java to work on API Level < 11
As discussed in issue #88 at helun/Ektorp
778f899

tleyden commented Oct 11, 2013

Thanks @beilharz, looks good.

tleyden referenced this issue in couchbase/couchbase-lite-android Oct 11, 2013

Closed

The required Android version should be decreased #115

@tleyden tleyden pushed a commit to couchbaselabs/Ektorp that referenced this issue Oct 11, 2013

Traun Leyden Merge pull request in ektorp issue #88: beilharz@778f899 c9d040f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment