Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android is all of a sudden DEAD - getCustomerInfo doesn't work and getOfferings #992

Open
6 tasks done
peazz opened this issue Feb 26, 2024 · 13 comments
Open
6 tasks done
Labels
bug Something isn't working

Comments

@peazz
Copy link

peazz commented Feb 26, 2024

Environment

  • Output of flutter doctor
[√] Flutter (Channel stable, 3.19.1, on Microsoft Windows [Version 10.0.22621.3155], locale en-GB)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.6.1)
[√] Android Studio (version 2022.3)
[√] VS Code (version 1.86.2)
[√] Connected device (4 available)
[√] Network resources
  • Version of purchases-flutter

6.21.1

  • Testing device version e.g.: iOS 15.5, Android API 30, etc.
Pixelel 4 / 7
API 33 / 34
  • How often the issue occurs- every one of your customers is impacted? Only in dev?

Live and dev

D/[Purchases] - DEBUG(19380): ℹ️ Debug logging enabled
D/[Purchases] - DEBUG(19380): ℹ️ SDK Version - 7.5.2
D/[Purchases] - DEBUG(19380): ℹ️ Package name - com.thrudayapp.thruday_app
D/[Purchases] - DEBUG(19380): 👤 Initial App User ID - 44650fcf-fc04-4274-9025-86da81be8e8f
D/[Purchases] - DEBUG(19380): ℹ️ Purchases configured with response verification: DISABLED
D/[Purchases] - DEBUG(19380): 👤 Identifying App User ID: 44650fcf-fc04-4274-9025-86da81be8e8f
D/[Purchases] - DEBUG(19380): ℹ️ Deleting old synced subscriber attributes that don't belong to 44650fcf-fc04-4274-9025-86da81be88e8f
D/[Purchases] - DEBUG(19380): ℹ️ App foregrounded
D/[Purchases] - DEBUG(19380): ℹ️ CustomerInfo cache is stale, updating from network in foreground.
D/[Purchases] - DEBUG(19380): Retrieving customer info with policy: FETCH_CURRENT
D/[Purchases] - DEBUG(19380): ℹ️ Updating pending purchase queue
D/[Purchases] - DEBUG(19380): ℹ️ Offerings cache is stale, updating from network in foreground
D/[Purchases] - DEBUG(19380): 😻 Start Offerings update from network.
D/[Purchases] - DEBUG(19380): ℹ️ Querying purchases
D/[Purchases] - DEBUG(19380): Request already scheduled with jitter delay, adding existing callbacks to unjittered request with key: BackgroundAwareCallbackCacheKey(cacheKey=[/subscribers/44650fcf-fc04-4274-9025-86da81be8e8f/offerings], appInBackground=false)
D/[Purchases] - DEBUG(19380): ℹ️ Updating pending purchase queue
D/[Purchases] - DEBUG(19380): ℹ️ Querying purchases
D/[Purchases] - DEBUG(19380): ℹ️ Found 3 unsynced attributes for App User ID: 44650fcf-fc04-4274-9025-86da81be8e8fSubscriberAttriibute(key=SubscriberAttributeKey('$email'), value=andy@pixelbin.com, setTime=Mon Feb 26 22:30:30 GMT 2024, isSynced=false)        
D/[Purchases] - DEBUG(19380): SubscriberAttribute(key=SubscriberAttributeKey('$displayName'), value=Andy Cresswell, setTime=Mon Feb 26 22:30:30 GMT 2024, isSynced=false)
D/[Purchases] - DEBUG(19380): SubscriberAttribute(key=SubscriberAttributeKey('$firebaseAppInstanceId'), value=2ad6b90895a966152a22675dcad73154, setTime=Mon Feb 26 22:30:30 GMT 2024, isSynced=false)
D/[Purchases] - DEBUG(19380): Product entitlement mappings are stale. Updating.
D/[Purchases] - DEBUG(19380): ℹ️ Listener set
D/[Purchases] - DEBUG(19380): ℹ️ Starting connection for com.android.billingclient.api.BillingClientImpl@dfbe16a
D/[Purchases] - DEBUG(19380): ℹ️ setEmail called
D/[Purchases] - DEBUG(19380): ℹ️ setDisplayName called
D/[Purchases] - DEBUG(19380): ℹ️ Billing Service Setup finished for com.android.billingclient.api.BillingClientImpl@dfbe16a
D/[Purchases] - DEBUG(19380): ℹ️ Updating pending purchase queue
D/[Purchases] - DEBUG(19380): ℹ️ Querying purchases
D/[Purchases] - DEBUG(19380): ℹ️ Cleaning previously sent tokens
D/[Purchases] - DEBUG(19380): ℹ️ Tokens already posted: []
D/[Purchases] - DEBUG(19380): ℹ️ Saving tokens []
D/[Purchases] - DEBUG(19380): ℹ️ Tokens already posted: []
D/[Purchases] - DEBUG(19380): ℹ️ No pending purchases to sync
D/[Purchases] - DEBUG(19380): ℹ️ Cleaning previously sent tokens
D/[Purchases] - DEBUG(19380): ℹ️ Tokens already posted: []
D/[Purchases] - DEBUG(19380): ℹ️ Saving tokens []
D/[Purchases] - DEBUG(19380): ℹ️ Tokens already posted: []
D/[Purchases] - DEBUG(19380): ℹ️ No pending purchases to sync
D/[Purchases] - DEBUG(19380): ℹ️ Cleaning previously sent tokens
D/[Purchases] - DEBUG(19380): ℹ️ Tokens already posted: []
D/[Purchases] - DEBUG(19380): ℹ️ Saving tokens []
D/[Purchases] - DEBUG(19380): ℹ️ Tokens already posted: []
D/[Purchases] - DEBUG(19380): ℹ️ No pending purchases to sync
D/[Purchases] - DEBUG(19380): Request already scheduled with jitter delay, adding existing callbacks to unjittered request with key: BackgroundAwareCallbackCacheKey(cacheKey=[/subscribers/44650fcf-fc04-4274-9025-86da81be8e8f], appInBackground=false)
D/[Purchases] - DEBUG(19380): ℹ️ setFirebaseAppInstanceID called
D/EGL_emulation(19380): app_time_stats: avg=90.27ms min=12.04ms max=555.66ms count=17
D/[Purchases] - DEBUG(19380): Billing connected with country code: GB
  • Steps to reproduce, with a description of expected vs. actual behavior
    Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

Describe the bug

25/02/2024 - Android stops completing futures...

  1. getCustomersInfo never completes
  2. getOfferings never compeletes
  3. Live and Sandbox
  4. No changes to cause this

When loading the subscriptions page and I try to load offerings;

/flutter (19380): ---------------------------------------------
I/flutter (19380): [is configured, true]
I/flutter (19380): ---------------------------------------------
I/flutter (19380): Settings up offerings
D/[Purchases] - DEBUG(19380): ℹ️ No cached Offerings, fetching from network
D/[Purchases] - DEBUG(19380): 😻 Start Offerings update from network.
D/[Purchases] - DEBUG(19380): Same call already in progress, adding to callbacks map with key: BackgroundAwareCallbackCacheKey(cacheKey=[/subscribers/44650fcf-fc04-4274-9025-86da81be8e8f/offerings], appInBackground=false)
D/[Purchases] - DEBUG(19380): Request already scheduled with jitter delay, adding existing callbacks to unjittered request with key: BackgroundAwareCallbackCacheKey(cacheKey=[/subscribers/44650fcf-fc04-4274-9025-86da81be8e8f/offerings], appInBackground=false)

And the code that produces the above debug log

@override
  void initState(){
    super.initState();

    Purchases.isConfigured.then((isConfigured) async {

      print('---------------------------------------------');
      print(['is configured', isConfigured]);
      
      // this never returns or completes!!
      print(['customerInfo', await Purchases.getCustomerInfo()]);
      
      if(await Purchases.appUserID != AuthedUser.get!.id){
        // login the user
        await Purchases.logIn(AuthedUser.get!.id);
        // ensure we have the latest customer info
        Provider.of<AppPurchaser>(context, listen: false)
          .updateCustomerInfo();
      }

      // ensure we can make payments
      if(await Purchases.canMakePayments()){
        // get our offerings for selected
        setupOfferings();
      } else {
        print('cant make purchases');
      }
    });

  }

  void setupOfferings() async {
    try {

      print('---------------------------------------------');
      print('Settings up offerings');
      
      // this does not return or complete!!
      offerings = await Purchases.getOfferings();
      

      if (offerings!.current != null) {
        
        if(null != offerings!.current!.monthly && null != offerings!.current!.annual){
          setState(() {
            subscriptions = [
              offerings!.current!.monthly!,
              offerings!.current!.annual!
            ];
          });
        }

      } else {
        FirebaseCrashlytics.instance.log('No offerings loaded, offerings: $offerings');
        
        setState(() {
          _error = 'There seem to be no offerings available at the moment. Please try again later.' as PlatformException;
        });
      }

    } on PlatformException catch (e) {
        FirebaseCrashlytics.instance.log(e.toString());
        setState(() {
          _error = e;
        });
    }
  }

I've checked the profiler, I see no network requests being made at all...
Network requests to my own custom API backend works
If I manually query the subscriber endpoint using POSTMAN, offerings return
Problem is only on Android, offerings / system works fine on Apple
No changes with in Play Developer to cause this

Literally, started for no reason

Additional context

I got to a point where I started going through commits and got it down to where I updated the versions of;

flutter_keyboard_visability: 6.0.0
wolt_modal_sheet: 0.4.1
flutter_quill: 9.2.12

I have epilepsy, I am struggling after this - I will further figure out tomorrow which of this plugins caused this.

I have analysed the rest of the commit and there is nothing that could stop network requests getting through.

Day 3: I have now added back in the above plugins, cleaned the installation and tried again - still working so, there is two possibilities here;

  1. The problem was with RevenueCat and they silently fixed it
  2. Something corrupted the installation when trying to apply the above plugins

I have obsessively checked all commits, nothing there could have caused this - I am lost for words and can't even offer any help to someone facing the same problem.

@peazz peazz added the bug Something isn't working label Feb 26, 2024
@RCGitBot
Copy link
Contributor

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@peazz
Copy link
Author

peazz commented Feb 27, 2024

I updated the details above with my findings

@mshmoustafa
Copy link
Contributor

Hey @peazz sorry for the delay on this, I read through your issue and it doesn't seem like it's something that would be affected by our backend. We checked our server logs to double check and didn't find any errors in our GET /offerings endpoint for your app. We also didn't have any incidents and haven't rolled anything out on our end that would address this issue.

Seems like redoing the plugin setup worked? Truly strange but it does indicate that the build on your machine got into a weird state. It's uncommon but it does happen enough to the point that we sometimes recommend redoing the install process if unexplained issues arise with seemingly no changes.

I'll get this on our @RevenueCat/sdk team's radar just in case. Sorry for the experience here, sounds like you've had a frustrating time. Let us know if there's anything else we can do to help.

@peazz
Copy link
Author

peazz commented Feb 27, 2024

I did....everything. Flutter clean, pub cache reload, the entire lot but problem persisted.

I've tried to replicate and for some reason I have been unable too, I have to catch up on stuff but its on my radar to try and find this. I found it so unique.

@mshmoustafa
Copy link
Contributor

Hey @peazz, the SDK team agrees that this was probably a corrupted installation somehow. It's really unfortunate it happened to you but it does happen in rare circumstances. I've also confirmed that we haven't shipped anything that would have silently fixed it. If you're not having any other issues, would it be ok if we closed this issue as resolved? You can always reach back out if something does happen in the future.

@peazz
Copy link
Author

peazz commented Mar 7, 2024

@mshmoustafa I would normally agree, I have been developing since v1 of flutter however, if I switch back to the branch, the issue reappears again.

Lets put it down to a config issue but if anyone else raises this, it would be wise to investigate. I got it down to the the platform calls that happen and never being returned from platform level functions.

@peazz
Copy link
Author

peazz commented Mar 9, 2024

I am coming back to this after having to change a product... somehow a yearly subscription was configured to be monthly period.

Now, this has brought me full circle;

  1. API call is reporting the new product
  2. purchases_flutter: await Purchases.getOfferings() only returns a single product

I am getting the impression that there is a caching mechnism that is potentially buggy and disregarding changes (I assume because they don't happen often)

@asilliahmet
Copy link

nope, you people are just bad at your jobs

@peazz
Copy link
Author

peazz commented May 18, 2024

nope, you people are just bad at your jobs

And whom is this directed at?

@asilliahmet
Copy link

getting a bit frustated here, having the exact same issue as you dude. revenuecat seems to be very finnicky to say the least

@peazz
Copy link
Author

peazz commented May 18, 2024

getting a bit frustated here, having the exact same issue as you dude. revenuecat seems to be very finnicky to say the least

It is, rolling your own solution is worse though and alternatives have more involved setups or higher fees.

Try rolling back any pubspec changes, I've noticed plugin updates can screw things sometimes.

@asilliahmet
Copy link

worked wonders thank you, rolled back to the last package json change.

@peazz
Copy link
Author

peazz commented May 18, 2024

worked wonders thank you, rolled back to the last package json change.

I'm pretty sure package updates may include overrides which messes with RevenueCat but honestly, I am way too busy bootstrapping with no investment, I have no time to chase it for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants