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

[cloud-firestore] Transactions fail with PlatformException #2293

Closed
YohanWadia opened this issue Apr 3, 2020 · 2 comments
Closed

[cloud-firestore] Transactions fail with PlatformException #2293

YohanWadia opened this issue Apr 3, 2020 · 2 comments
Labels
impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) plugin: cloud_firestore type: bug Something isn't working

Comments

@YohanWadia
Copy link

YohanWadia commented Apr 3, 2020

Hi,
Searched every where... and seen a lot of bugs with Transactions in Firestore pkg... but this one is new.

  • Im running it on stable channel(Android Studio)
  • Ive got the same error on device and emulator (Both Androids)
  • All my other CRUD operations work perfectly.

CODE:

DocumentReference myDocRef = collectionRef.document("Uuid");
    Firestore.instance.runTransaction((Transaction tx) async {
      print("000000");
      DocumentSnapshot docSnap = await tx.get(myDocRef);
      int x= docSnap.data['age'];
      x++;print("Age ++: $x");
      await tx.update(myDocRef, <String, dynamic>{'age': x})
          .catchError((e) {print("ERROR= $e");})
          .whenComplete(() {print("Transaction DONE!!!");});
    });

the above Document has only 2 fields: name & age. Im trying to read age... and then increment it by +1... and then update the document with the new age.
the above code fails even before it can print "000000".

> ERROR:
> PlatformException(Error performing transaction, Attempt to invoke virtual method 'void android.app.Activity.runOnUiThread(java.lang.Runnable)' on a null object reference, null)


> FULL ERROR:
> E/flutter (22677): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(Error performing transaction, Attempt to invoke virtual method 'void android.app.Activity.runOnUiThread(java.lang.Runnable)' on a null object reference, null)
> E/flutter (22677): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
> E/flutter (22677): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
> E/flutter (22677): <asynchronous suspension>
> E/flutter (22677): #2      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:349:48)
> E/flutter (22677): #3      MethodChannelFirestore.runTransaction (package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart:123:10)
> E/flutter (22677): #4      Firestore.runTransaction (package:cloud_firestore/src/firestore.dart:85:22)
> E/flutter (22677): #5      _MyHomePageState.UpdateTransactionRW (package:firestorecrud/main.dart:229:24)
> E/flutter (22677): #6      _MyHomePageState.build.<anonymous closure> (package:firestorecrud/main.dart:90:19)
> E/flutter (22677): #7      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
> E/flutter (22677): #8      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
> E/flutter (22677): #9      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
> E/flutter (22677): #10     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
> E/flutter (22677): #11     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
> E/flutter (22677): #12     BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:199:7)
> E/flutter (22677): #13     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:467:9)
> E/flutter (22677): #14     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
> E/flutter (22677): #15     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:117:9)
> E/flutter (22677): #16     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
> E/flutter (22677): #17     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:115:18)
> E/flutter (22677): #18     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:7)
> E/flutter (22677): #19     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
> E/flutter (22677): #20     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
> E/flutter (22677): #21     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
> E/flutter (22677): #22     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
> E/flutter (22677): #23     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
> E/flutter (22677): #24     _rootRunUnary (dart:async/zone.dart:1138:13)
> E/flutter (22677): #25     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
> E/flutter (22677): #26     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
> E/flutter (22677): #27     _invoke1 (dart:ui/hooks.dart:273:10)
> E/flutter (22677): #28     _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)

====================
flutter doctor -v

[√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.18363.720], locale en-US)
    • Flutter version 1.12.13+hotfix.9 at C:\flutterio\flutter
    • Framework revision f139b11009 (4 days ago), 2020-03-30 13:57:30 -0700
    • Engine revision af51afceb8
    • Dart version 2.7.2


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\Yo\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[!] IntelliJ IDEA Community Edition (version 2019.2)
    • IntelliJ at D:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.2.3
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[!] VS Code (version 1.43.0)
    • VS Code at C:\Users\Yo\AppData\Local\Programs\Microsoft VS Code
    X Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (1 available)
    • AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

! Doctor found issues in 2 categories.
@iapicca iapicca added the type: bug Something isn't working label Apr 3, 2020
@kirstywilliams kirstywilliams added impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) plugin: cloud_firestore labels Apr 20, 2020
@kirstywilliams kirstywilliams changed the title Transactions fail with Error: PlatformException(Error performing transaction, Attempt to invoke virtual method 'void android.app.Activity.runOnUiThread(java.lang.Runnable)' on a null object reference, null) [cloud-firestore] Transactions fail with PlatformException Apr 20, 2020
@YohanWadia
Copy link
Author

@iapicca , I just checked back after bit of time... has anything developed on this topic?

@Salakar
Copy link
Member

Salakar commented Jul 7, 2020

Hey, as part of our on-going work for #2582, this has been resolved in our Firebase Firestore rework (#2913) - which has now been merged into master. We'll look at publishing some prereleases in the next few days. Thank you

@Salakar Salakar closed this as completed Jul 7, 2020
@firebase firebase locked and limited conversation to collaborators Aug 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) plugin: cloud_firestore type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants