Open drekyyy opened 1 week ago
Hi @drekyyy, Very interesting finding and thank you for sharing it. I understand the significance and let’s try to resolve the issue. Based on the exception message, it seems like the method channel is being consumed already when another Google Pay availability check happens. I tried to reproduce it with the current example implementation but the issue does not occur (debug and release mode). At least on my devices or a simulator.
I see in your video that the Google Pay button disappears when leaving the app. And it seems that it is being rendered (maybe a new instance is created?) again when going back into the app. In our example app, the Google Pay component keeps its state. Maybe that could be a difference.
Would it be possible to check if multiple instances of the Google Pay component are created? Do you might have time to check our example project on your device as well? The project should work out of the box by just adding your credentials into the config file.
In the meantime, I will investigate further and check the platform channel implementation. I will adjust the example and test multiple Google Pay button instances.
https://github.com/user-attachments/assets/0bd11093-5300-4dab-bbcb-68c9eb1fd350
Hey @Robert-SD,
I think you are on to something, I also noticed that it was being rebuilt. I turned the widget into a const and so far the crash has not happened. I will most likely update you tomorrow whether we managed to reproduce the crash or not.
Your insight is very appreciated.
Describe the bug
The app sometimes throws a fatal exception when user comes back to the app after minimizing it for a short period of time, while on the screen that contains google pay component, or even a screen after that (one that has the gpay screen below on navigator stack). It wasnt hard to reproduce it in app's release mode (codemagic build), but when trying in debug mode on the other hand, it was close to impossible. In our case, this bug is very serious, because one of our payment methods (BLIK) requires the user to minimize the app to confirm the payment in bank app.
To Reproduce
Video I went back and forth from foreground to background, then the app crashed, and upon opening it, you are greeted by its home screen
https://github.com/user-attachments/assets/81897c37-8b47-4c07-99d1-54ad3bd4f7cf
Smartphone
App