Skip to content
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

uCrop hangs due to the presence of an AsyncTask background thread in wait/sleep state or in loop #550

Closed
SharkFourSix opened this issue Jul 31, 2019 · 2 comments

Comments

@SharkFourSix
Copy link

SharkFourSix commented Jul 31, 2019

Do you want to request a feature or report a bug?
Report a bug

What is the current behavior?
UCrop activity becomes disabled when an AsyncTask instance is run in the background and if the doInBackground method is in a loop or the task's thread is in a wait state.

What is the expected behavior?

UCrop activity should not stall/hang.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

It seems UCrop doesn't play well with AsyncTasks running in a foreground service?

Here's a simple class to reproduce this. Fist, launch the task and then launch UCrop. It could be Android's scheduling system. IDK.

public class AnActivity extends AppCompatActivity {
    @Override protected void onCreate(...){
        // setup some views. Possibly a button to invoke uCrop
        startService(new Intent(this, AService.class));
    }
}
public class AService extends Service {
    public void onCreate(){
        new BlockingTask().execute();
    }
  // ...
}
public static class BlockingTask extends AsyncTask<Void, Void, Void> {
        @Override
        protected Void doInBackground(Void... voids) {
            Log.v("BlockingTask", "doInBackground");
            try {
                // Will block UCrop for 60 seconds.
                // Even wrapping #execute in another thread will still block UCrop
                Thread.sleep(TimeUnit.SECONDS.toMillis(60));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            Log.v("BlockingTask", "doInBackground");
            return null;
        }
    }

Please attach any image files, URL and stack trace that can be used to reproduce the bug.

Which versions of uCrop, and which Android API versions are affected by this issue? Did this work in previous versions of uCrop?

uCrop 2.2.3-native
SDK 28, Android Pie

EDIT

My solution was to move my worker method to a Thread class instead of using AsyncTask.

@SharkFourSix SharkFourSix changed the title uCrop hangs if connected to the Internet is running in the background uCrop hangs if connected to the Internet or an AsyncTask background thread is running Jul 31, 2019
@SharkFourSix SharkFourSix changed the title uCrop hangs if connected to the Internet or an AsyncTask background thread is running uCrop hangs due to the presence of an AsyncTask background thread in wait/sleep state or in loop Aug 1, 2019
@SharkFourSix
Copy link
Author

Not closing until confirmed.

@mytxoo
Copy link

mytxoo commented Feb 4, 2020

android10
#1202 android.content.ActivityNotFoundException
Unable to find explicit activity class {com.tencent.qcloud.tim.tuikit/com.yalantis.ucrop.UCropActivity}; have you declared this activity in your AndroidManifest.xml?
com.yalantis.ucrop.UCrop.start(UCrop.java:138)
The lower version can

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants