Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ParseInstaller.getCurrentInstallation().saveInBackground() is freezing my application

I am finding that about 1/5 of my tests are freezing, and after some searching for the problem I have narrowed it down to the line:

ParseInstallation.getCurrentInstallation().saveInBackground();

I am using Parse 1.5.1, and an Android 4.4.2 device. My application class looks like:

public class InitApplication extends Application {

 @Override
    public void onCreate() {
        super.onCreate();
        Parse.initialize(this, "my_App_ID", "my_Client_Key");
        PushService.setDefaultPushCallback(this, MainActivity.class);
        System.out.println("execution DOES reach here");
        ParseInstallation.getCurrentInstallation().saveInBackground();
    System.out.println("execution DOES NOT reach here");
    }
}

The behaviour on my device is that I will first see a blank white screen for about 5 seconds, and then the screen goes black. I am not sure how long the screen stays black, as I usually force close. I've let it sit for about 10 minutes once with no change. I am unable to press the back button and any touch on the screen does nothing. I am forced to use my home button, then force the application to close. Upon reopening the application, it behaves and functions normally.

Further research led me to find this post: https://www.parse.com/questions/android-saveinbackground-lock-the-main-thread

But still, I have been unable to find a solution. One suggestion in the above post is to simply move the location of this code. I have tried this to some point after my main activity's onCreate() method (not to be confused with the application's onCreate() method). Behaviour appeared to be normal up until I got to the point where the getCurrentInstallation.saveInBackground() code is called, where my application froze and failed to respond until I forced it closed.

Are there any solutions to this problem?

like image 549
h_k Avatar asked Jul 04 '14 15:07

h_k


2 Answers

I encountered the same problem as well using Parse SDK 1.5.1.

And I just downloaded the latest SDK 1.6.0 and problem solved.

Link to download the latest SDK.

like image 189
Nic Huang Avatar answered Oct 05 '22 12:10

Nic Huang


You can track reported issue here: Parse installation save causing app freeze

I already provided (confidentially) thread dump traces from my app. However at time of writing this post there is no useful feedback from Parse guys.

My humble opinion after looking into traces is a deadlock causing this issue after some trouble with server interaction. But it's just guessing.

Link updated

like image 35
littleli Avatar answered Oct 05 '22 12:10

littleli