MemorizingTrustManager icon indicating copy to clipboard operation
MemorizingTrustManager copied to clipboard

Endless loop when clicking on "Cancel" with certain activity themes

Open rfc2822 opened this issue 9 years ago • 5 comments

Hello,

I'm trying to use MemorizingTrustManager with HttpsUrlConnection (setSSLSocketFactory, setHostnameVerifier). It's a quite simple setup so I don't think I've done anything wrong; it' works quite well, but there is one problem:

When clicking on "Cancel" (= the certificate shall not be used), the HttpsUrlConnection (I think it's the getInputStream() method) takes forever and according to adb, there's an endless loop + a memory leak, too.

Have you ever heard of such issues with HttpsUrlConnection and "Cancel", or do you know a working example of HttpsUrlConnection + MTM?

Thanks for your work.

rfc2822 avatar Dec 16 '15 10:12 rfc2822

Hi, the default example in the repository's example directory is using HttpsURLConnection, and there are no known issues with the "Cancel" button. I just verified that on Android6. Can you provide more information or maybe a stack trace?

ge0rg avatar Dec 16 '15 11:12 ge0rg

Thanks for testing this. The problem is that it doesn't crash… I'll try to find out how to get a stack trace or maybe profiling information to see what's actually going on.

rfc2822 avatar Dec 16 '15 11:12 rfc2822

Funny, it's related to the android:theme of MemorizingActivity. With android:theme="@android:style/Theme.Translucent.NoTitleBar", it works as expected, but with android:theme="@style/Theme.AppCompat.Light.NoActionBar" (which I have used before; it's a support library theme) there's an UI endless loop (maybe only on Samsung, as I have seen com.samsung.* classes in the profiling results).

Do you have any hints which themes are acceptable / how the support library's Material theme can be used?

rfc2822 avatar Dec 16 '15 12:12 rfc2822

From various tested themes, only @android:style/Theme.Translucent.NoTitleBar and @style/Theme.AppCompat.Light.Dialog seem to work, while the endless loop occurs for all others… very strange, but I guess this is not related to MTM.

Maybe it would be good to mention which themes are usable (and even better, why) in the documentation.

rfc2822 avatar Dec 16 '15 12:12 rfc2822

To be honest, I wasn't even aware that this is a problem, and I have no idea what the cause is.

I had the hope to bring #29 into a shape that would allow completely removing the MTM activity, but there was no progress in a looong time. I will keep this issue open for now, for documentation reasons, and make a statement in the README someday ;-)

ge0rg avatar Dec 16 '15 17:12 ge0rg