Retrofit crashes after unlock device

Hi there,

I’m facing a mysterious crash with the following scenario:

  1. Launch the app
  2. Lock the device
  3. Unlock the device (with home button)
  4. Make an HTTP request
  5. The app crashes

I can’t reproduce it on the simulator, only on a real device, and I can’t debug the crash:

  • The debugger detaches when the device gets locked
  • Even if I declare a custom UncaughtExceptionHandler to print the stack trace, nothing appears
    so I don’t kown what is happening.

The only thing I’m sure of, is that the crash happens immediately after a call to an HTTP API. I can log the call, and sometimes the result (not always), then the app crashes.

I use Retrofit for the all the network part, so I can’t manage the connections myself. I’ve read in this post that it could be a matter of unclosed session.

How can I deal with this problem? Has anyone already faced the same crash?

Check baseUrl after unlocking the device.

Regards,
Saeed.

Hi saeed, thanks for your reply. The baseUrl is fine, sometimes I even get the result of the call before the crash, so I don’t think it is related to the request itself.

Hi,

I also noticed this weird behavior on my iOS device.
This behavior may refer to [SOLVED] iOS app crashes from Broken Pipe .
What actually helped was the following line of code in my Main Class:

    @Override
    public boolean applicationDidFinishLaunchingWithOptions(UIApplication application, NSDictionary launchOptions) {

        apple.c.Globals.sigignore(13); // avoid SIGPIPE Crashs after 2nd launch
        ....

Regards,
Jucl

1 Like

@Jucl It’s been 2 years, why did I not see your reply sooner!!! I found a workaround but last week the issue came back and I see the fix only now, arrrgh :smile:

Thank you so much! :+1:

1 Like