Adyen / adyen-android

Adyen Android Drop-in and Components
https://docs.adyen.com/checkout/android
MIT License
126 stars 65 forks source link

Black background behind payment methods on Android API 28 #284

Closed geertjan-tiqets closed 3 years ago

geertjan-tiqets commented 4 years ago

Describe the bug Since updating from Adyen SDK 3.6.6 to 3.7.3, when running on Android API 28, when the payment methods popup is shown, the background is opaque black.

To Reproduce Start the Adyen payment flow on an API 28 emulator.

Expected behavior On other Android versions, the payment methods background is translucent black.

Screenshots Screenshot_1606236023

Additional information I have tried disabling custom styling we do for the Adyen SDK. It did not make a difference.

caiofaustino commented 4 years ago

Hi there,

I just tested our example app on an API 28 simulator and don't see that issue happening. Can you maybe check your default AppTheme? Try overriding our Checkout theme like this <style name="AdyenCheckout" parent="Theme.MaterialComponents.Light.Bridge" />

geertjan-tiqets commented 4 years ago

Hi,

In our app we are using <style name="AdyenCheckout" parent="Theme.MaterialComponents.Light.DarkActionBar">, but I just tried changing it to Theme.MaterialComponents.Light.Bridge, and it didn't make a difference for this issue.

I have tried some more different things for styling (different AppTheme, giving our Activity that starts the Adyen flow a different theme, etc.), but the result is always the same.

I went through the Adyen example app, to see if I could spot anything we do differently, but I haven't found anything else. So this is a bit of a mystery then.

If I can find some time, the next thing I will try is running the Adyen example app myself, and if indeed the problem does not occur, gradually start changing things towards how our own app is set up, until the problem starts happening.

caiofaustino commented 4 years ago

Yeah sounds good, let me know if you have any other questions in the meantime.

geertjan-tiqets commented 4 years ago

I've done more work on this, but still haven't been able to fix it, or pinpoint the exact problem.

I wasn't able to test with the Adyen example app, because our backend implementation is not compatible with it. But I made further effort to replicate the example app, by creating a new Activity in our own app, that is configured the same way as the example app Activity. However, the black screen bug still happened.

The only big difference between our app and the example app, is that the example app is still using the older Android AppCompat libraries, while out app is using AndroidX. I suspect the problem originates from this somehow. However, this would take quite some work to verify.

Seeing how the Adyen SDK 4.0 is switching to AndroidX, I think we're going to just wait for that to be released.

caiofaustino commented 4 years ago

Please note that the SDK 4.0 will have other changes that will probably requires backend work as well. And I have a local test application with AndroidX that also doesn't have this issue so I don't think that's related. Have you tried using the layout inspector to see what's going on?

Also check this style to see if it could be causing any issues for you. https://github.com/Adyen/adyen-android/blob/develop/drop-in/src/main/res/values/styles.xml#L29

geertjan-tiqets commented 3 years ago

I've been digging a bit deeper into this. The root cause of this problem is not the Adyen SDK, it's a problem in Android API 28 itself.

Normally, when you create a transparent Activity in Android (using <item name="android:windowIsTranslucent">true</item> and <item name="android:windowBackground">@android:color/transparent</item>), the Activity below it is put in the PAUSED state, instead of the STOPPED state. This allows the underlying Activity to stay visible behind the transparent Activity. However, in Android API 28, the underlying Activity is put in the STOPPED state, as if the transparent Activity is not transparent. This causes the underlying Activity to become black, and hence why the translucent Activity is now showing a black background.

So this seems like a pretty clear cut, completely reproducible, bug in Android API 28. However, the mystery is how this bug interacts with the Adyen SDK. Somehow, simply having the Adyen SDK 3.6 dependency (not even calling any Adyen code) makes this black screen problem go away! But even then not consistently. And the Adyen SDK 3.7 dependency doesn't have the same effect, even though I have not found any related changes in the 3.6 to 3.7 diff.

So for example, in our Tiqets app, I reproduced this bug by creating a new test Activity. And indeed, here having the Adyen SDK 3.6 makes the transparent Activity work. Removing the Adyen SDK dependency or changing it to 3.7 makes the black screen problem return. However, if I create a fresh new Android app in Android Studio, and reproduce the bug in there, and then include Adyen SDK 3.6, it doesn't have any effect!

So yeah, I'm stuck again. It seems this bug always happens except sometimes if Adyen SDK 3.6 is present. It's a mystery.

If there's anything else in the Adyen SDK code you can think of that could affect this, I'd be glad to hear it. For now I'm considering this an Android bug.

caiofaustino commented 3 years ago

The fact that on your test it happens on 3.7 and not on 3.6 is really bugging me.

simply having the Adyen SDK 3.6 dependency (not even calling any Adyen code) makes this black screen problem go away!

So we fixed the framework bug somehow? 🤣 Indeed I don't see any related changes between 3.6 and 3.7, the manifest didn't change since 3.4.1, and the style for that activity hasn't changed either.

However, if I create a fresh new Android app in Android Studio, and reproduce the bug in there, and then include Adyen SDK 3.6, it doesn't have any effect!

That indicates to me that the issue, or rathe the fixing of the framework issue, could be related with some interaction between our styling and yours. Also can you confirm if using 3.6 where the issue doesn't happen, the state of the background activity is still STOPPED?

geertjan-tiqets commented 3 years ago

Also can you confirm if using 3.6 where the issue doesn't happen, the state of the background activity is still STOPPED?

Yes, I can confirm. [Edit: I meant I can confirm this is not the case. :sweat_smile: With Adyen 3.6 the background activity state is PAUSED, not STOPPED.] Just double checked one more time, because I can also hardly believe it. :smile:

I also tried changing our app's theme name from AppTheme to AppTestTheme, but it makes no difference.

(All of the above still only on Android API 28)

caiofaustino commented 3 years ago

Wow, that's really bizarre indeed. So the change happened between 3.6.6 and 3.7.0 right? I couldn't find anything on the diff that would remotely have an impact on this afaik, sorry 😕

geertjan-tiqets commented 3 years ago

Yep, I also went over the diff between 3.6.6 and 3.7.0 but couldn't find anything.

There seems to be one dependency change, which is the added com.android.support:design in the mbway-ui module. But I checked and it has no effect on our app's dependency tree.

So yeah, for now we will just live with this mystery wrapped in an enigma. :sweat_smile: You can close this issue if you want.