Picasso: Error loading image on Android 7.0+

Created on 7 Jan 2017  路  13Comments  路  Source: square/picasso

I'm running into an error loading images from certain URLs on certain devices. I tried on:

  • Nexus 5 running Android 5.1 (no error)
  • Nexus 5X running Android 7.0 (error)
  • Nexus 5X running Android 7.1.1 (error)

I'm using Picasso version 2.5.2. I turned on logging with Picasso.with(this).setLoggingEnabled(true); and gives the following stacktrace:

01-06 15:12:06.021   881  3600 I ActivityManager: Start proc 5709:com.formagrid.hellotest/u0a104 for activity com.formagrid.hellotest/.HelloActivity
01-06 15:12:06.048  5709  5716 I art     : Debugger is no longer active
01-06 15:12:06.048  5709  5716 I art     : Starting a blocking GC Instrumentation
01-06 15:12:06.069  5709  5709 W System  : ClassLoader referenced unknown path: /data/app/com.formagrid.hellotest-2/lib/arm64
01-06 15:12:06.103  5709  5709 W Settings: Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
01-06 15:12:06.108  5709  5709 D Picasso : Main        created      [R0] Request{http://www.desicomments.com/wp-content/uploads/LOL-With-Emoji.jpg}
01-06 15:12:06.109  5709  5709 D Picasso : Main        created      [R1] Request{https://forma_app_filepicker_dev-test-staging.s3.amazonaws.com/profilePics%2FGPeekrQMepSJvusaFOng_66.png?sz=36}
01-06 15:12:06.112  5709  5734 D Picasso : Dispatcher  enqueued     [R0]+3ms 
01-06 15:12:06.112  5709  5736 D Picasso : Hunter      executing    [R0]+4ms 
01-06 15:12:06.113  5709  5734 D Picasso : Dispatcher  enqueued     [R1]+3ms 
01-06 15:12:06.114  5709  5737 D Picasso : Hunter      executing    [R1]+5ms 
01-06 15:12:06.118  5709  5737 D NetworkSecurityConfig: No Network Security Config specified, using platform default
01-06 15:12:06.157  5709  5738 I Adreno  : QUALCOMM build                   : a5b4970, If5818605d9
01-06 15:12:06.157  5709  5738 I Adreno  : Build Date                       : 10/12/16
01-06 15:12:06.157  5709  5738 I Adreno  : OpenGL ES Shader Compiler Version: XE031.09.00.04
01-06 15:12:06.157  5709  5738 I Adreno  : Local Branch                     : N24D
01-06 15:12:06.157  5709  5738 I Adreno  : Remote Branch                    : 
01-06 15:12:06.157  5709  5738 I Adreno  : Remote Branch                    : 
01-06 15:12:06.157  5709  5738 I Adreno  : Reconstruct Branch               : 
01-06 15:12:06.163  5709  5738 I OpenGLRenderer: Initialized EGL, version 1.4
01-06 15:12:06.163  5709  5738 D OpenGLRenderer: Swap behavior 1
01-06 15:12:06.184   881   901 I ActivityManager: Displayed com.formagrid.hellotest/.HelloActivity: +175ms
01-06 15:12:06.349  5709  5736 D Picasso : Hunter      decoded      [R0]+241ms 
01-06 15:12:06.350  5709  5734 D Picasso : Dispatcher  batched      [R0]+242ms for completion
01-06 15:12:06.432  4433  4575 W SearchService: Abort, client detached.
01-06 15:12:06.500  4274 31021 E ctxmgr  : [ProducerActiveIntervalImpl]closeActiveInterval: Error: ongoing, trying to close
01-06 15:12:06.507  4274  5307 I PlaceInferenceEngine: [anon] Setup for configuration 105:[]
01-06 15:12:06.507  4274  5307 I PlaceInferenceEngine: [anon] Active modules after start(): 0
01-06 15:12:06.531   510   647 D audio_hw_primary: disable_audio_route: usecase(1) reset and update mixer path: low-latency-playback
01-06 15:12:06.545   510   647 D audio_hw_primary: disable_snd_device: snd_device(78: vi-feedback)
01-06 15:12:06.545   510   647 D audio_hw_primary: disable_audio_route: usecase(21) reset and update mixer path: spkr-vi-record
01-06 15:12:06.584  5709  5734 D Picasso : Dispatcher  delivered    [R0]+476ms 
01-06 15:12:06.584  5709  5709 D Picasso : Main        completed    [R0]+476ms from DISK
01-06 15:12:07.095  5709  5734 D Picasso : Dispatcher  retrying     [R1]+985ms 
01-06 15:12:07.102  5709  5752 D Picasso : Hunter      executing    [R1]+992ms 
01-06 15:12:07.801  5709  5734 D Picasso : Dispatcher  retrying     [R1]+1690ms 
01-06 15:12:07.803  5709  5736 D Picasso : Hunter      executing    [R1]+1693ms 
01-06 15:12:07.811  5709  5734 D Picasso : Dispatcher  batched      [R1]+1700ms for error
01-06 15:12:08.054  5709  5709 D Picasso : Main        errored      [R1]+1944ms 
01-06 15:12:08.057  5709  5734 D Picasso : Dispatcher  delivered    [R1]+1946ms 

The image loads fine in Chrome on the phone. I don't think it's an https issue because I can load other https images.

Dummy project to repro the issue: https://github.com/patriciali/sandbox_android/tree/1d4cae8ccd4be66740cdc834865d94ad73bf445f

Most helpful comment

So tl;dr

1) This is not a Picasso/OkHttp/etc. bug.
2) This can be avoided by not using underscores in your (sub)domain name
3) If this answer is still not satisfactory then you will want to file a bug with the Android team stating that you don't find the required conformance to RFC 3490 specification satisfactory

All 13 comments

Same issue here o/

The issue is only for Nougat devices.

Was able to reproduce given that sample app on an API 25 emulator, and it looks like the exception is,

javax.net.ssl.SSLHandshakeException: java.lang.IllegalArgumentException: Invalid input to toASCII: forma_app_filepicker_dev-test-staging.s3.amazonaws.com

Created an updated version of that sandbox app https://github.com/caseykulm/sandbox_android to target api 25, updated all support lib version, using OkHttp3, OkHttp3 logging-interceptor, and picasso2-okhttp3-downloader. Also added a network_security_config.xml file and added it to the AndroidManifest.xml

Now clearly getting this log.

? I/art: Not late-enabling -Xcheck:jni (already on)
? W/art: Unexpected CPU variant for X86 using defaults: x86_64
com.formagrid.hellotest W/System: ClassLoader referenced unknown path: /data/app/com.formagrid.hellotest-2/lib/x86_64
com.formagrid.hellotest D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
com.formagrid.hellotest W/Settings: Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
com.formagrid.hellotest D/Picasso: Main        created      [R0] Request{https://forma_app_filepicker_dev-test-staging.s3.amazonaws.com/profilePics%2FGPeekrQMepSJvusaFOng_66.png?sz=36}
com.formagrid.hellotest D/Picasso: Dispatcher  enqueued     [R0]+11ms 
com.formagrid.hellotest D/Picasso: Hunter      executing    [R0]+27ms 

                                   [ 01-16 10:33:12.971 16350:16350 W/         ]
                                   Process pipe failed
com.formagrid.hellotest D/OkHttp: --> GET https://forma_app_filepicker_dev-test-staging.s3.amazonaws.com/profilePics%2FGPeekrQMepSJvusaFOng_66.png?sz=36 http/1.1
com.formagrid.hellotest D/OkHttp: --> END GET
com.formagrid.hellotest I/OpenGLRenderer: Initialized EGL, version 1.4
com.formagrid.hellotest D/OpenGLRenderer: Swap behavior 1
com.formagrid.hellotest E/EGL_emulation: tid 16378: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
com.formagrid.hellotest W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x76c1ca6a7080, error=EGL_BAD_MATCH
com.formagrid.hellotest D/OkHttp: <-- HTTP FAILED: javax.net.ssl.SSLHandshakeException: java.lang.IllegalArgumentException: Invalid input to toASCII: forma_app_filepicker_dev-test-staging.s3.amazonaws.com
com.formagrid.hellotest D/Picasso: Dispatcher  retrying     [R0]+890ms 
com.formagrid.hellotest D/Picasso: Hunter      executing    [R0]+891ms 
com.formagrid.hellotest D/OkHttp: --> GET https://forma_app_filepicker_dev-test-staging.s3.amazonaws.com/profilePics%2FGPeekrQMepSJvusaFOng_66.png?sz=36 http/1.1
com.formagrid.hellotest D/OkHttp: --> END GET
com.formagrid.hellotest D/OkHttp: <-- HTTP FAILED: javax.net.ssl.SSLHandshakeException: java.lang.IllegalArgumentException: Invalid input to toASCII: forma_app_filepicker_dev-test-staging.s3.amazonaws.com
com.formagrid.hellotest D/Picasso: Dispatcher  retrying     [R0]+1539ms 
com.formagrid.hellotest D/Picasso: Hunter      executing    [R0]+1540ms 
com.formagrid.hellotest D/OkHttp: --> GET https://forma_app_filepicker_dev-test-staging.s3.amazonaws.com/profilePics%2FGPeekrQMepSJvusaFOng_66.png?sz=36 http/1.1
com.formagrid.hellotest D/OkHttp: Cache-Control: max-stale=2147483647, only-if-cached
com.formagrid.hellotest D/OkHttp: --> END GET
com.formagrid.hellotest D/OkHttp: <-- 504 Unsatisfiable Request (only-if-cached) https://forma_app_filepicker_dev-test-staging.s3.amazonaws.com/profilePics%2FGPeekrQMepSJvusaFOng_66.png?sz=36 (1ms)
com.formagrid.hellotest D/OkHttp: <-- END HTTP (0-byte body)
com.formagrid.hellotest D/Picasso: Dispatcher  batched      [R0]+1545ms for error
com.formagrid.hellotest D/Picasso: Main        errored      [R0]+1779ms 
com.formagrid.hellotest D/Picasso: Dispatcher  delivered    [R0]+1779ms 

Getting to this line in the Android source for IDN https://android.googlesource.com/platform/libcore/+/refs/heads/master/ojluni/src/main/java/java/net/IDN.java#112 with an exception,

The input does not conform to the STD 3 ASCII rules. line:  0. preContext:  a_ap. postContext: r_dev-test-staging

which is the Android source that is eventually called from this line in OkHttp https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/internal/connection/RealConnection.java#L267

So tl;dr

1) This is not a Picasso/OkHttp/etc. bug.
2) This can be avoided by not using underscores in your (sub)domain name
3) If this answer is still not satisfactory then you will want to file a bug with the Android team stating that you don't find the required conformance to RFC 3490 specification satisfactory

Here's the same image hosted on https with a proper url format for reference https://i.imgur.com/iHsr4Nd.png

And it works 馃憤

On 7.0+ I still see the issue of images not rendering. I add the linePicasso.with(context).setLoggingEnabled(true); to my Application class where Picasso is instantiated and the images start rendering magically. Any insights why the image won't render on 7.0 and above?

@caseykulm WOW! that's some great sleuthing.

closing since it's not Picasso bug

You can try to change the protocol to HTTP instead on this error and retry the connection.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StErMi picture StErMi  路  6Comments

bakztfuture picture bakztfuture  路  6Comments

paatz04 picture paatz04  路  6Comments

JakeWharton picture JakeWharton  路  7Comments

JakeWharton picture JakeWharton  路  3Comments