plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Bug]: share_plus exception prevents further use

Open TheCarpetMerchant opened this issue 2 years ago • 6 comments

Platform

Android 13

Plugin

share_plus

Version

7.0.2

Flutter SDK

3.10.5

Steps to reproduce

  1. Ask share_plus to share a file that doesn't exist.
  2. Ask share_plus to share a file that exists.

From then on, any attempt to share is met with the error below.

Code Sample

No response

Logs

E/flutter ( 6836): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(Share callback error, prior share-sheet did not call back, did you await it? Maybe use non-result variant, null, null)
E/flutter ( 6836): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
E/flutter ( 6836): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
E/flutter ( 6836): <asynchronous suspension>
E/flutter ( 6836): #2      MethodChannelShare.shareFilesWithResult (package:share_plus_platform_interface/method_channel/method_channel_share.dart:134:9)
E/flutter ( 6836): <asynchronous suspension>
E/flutter ( 6836):

Flutter Doctor

[√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [Version 10.0.19045.3086], locale fr-BE)
    • Flutter version 3.10.5 on channel stable at D:\Code\Flutter\sdk\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 796c8ef792 (3 weeks ago), 2023-06-13 15:51:02 -0700
    • Engine revision 45f6e00911
    • Dart version 3.0.5
    • DevTools version 2.23.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\user\AppData\Local\Android\sdk
    • Platform android-33, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio 2022\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.6)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.1.32421.90
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] Android Studio (version 2022.2)
    • Android Studio at C:\Program Files\Android\Android Studio 2022
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)

[√] VS Code (version 1.77.3)
    • VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.44.0

[√] VS Code, 64-bit edition (version 1.79.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.44.0

[√] Connected device (2 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator)
    • Windows (desktop)            • windows       • windows-x64 • Microsoft Windows [Version 10.0.19045.3086]

[√] Network resources
    • All expected network resources are available.

• No issues found!

Checklist before submitting a bug

  • [X] I Google'd a solution and I couldn't find it
  • [X] I searched on StackOverflow for a solution and I couldn't find it
  • [X] I read the README.md file of the plugin
  • [X] I'm using the latest version of the plugin
  • [X] All dependencies are up to date with flutter pub upgrade
  • [X] I did a flutter clean
  • [X] I tried running the example project

TheCarpetMerchant avatar Jul 01 '23 13:07 TheCarpetMerchant

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Sep 30 '23 00:09 github-actions[bot]

@nohli It seems this repo is abandonned, and you're the latest contributor. Is it abandonned ? If so, making a +1 version of the packages to notify anyone using them would be good.

TheCarpetMerchant avatar Oct 01 '23 09:10 TheCarpetMerchant

Hi @TheCarpetMerchant, the plus_plugins are actively maintained by the Fluttercommunity.

Not every issue is addressed directly, that doesn't mean it's abandoned: Screenshot 2023-10-05 at 12 53 21

Would you be interested in making your first contribution and try fixing this bug? Otherwise I'm going to try reproducing and fixing it.

nohli avatar Oct 05 '23 10:10 nohli

I have no native experience, so I wouldn't be able to do much.

TheCarpetMerchant avatar Oct 05 '23 11:10 TheCarpetMerchant

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Jan 04 '24 00:01 github-actions[bot]

Up

TheCarpetMerchant avatar Jan 04 '24 11:01 TheCarpetMerchant

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Apr 05 '24 00:04 github-actions[bot]

The issue can be reproduced calling with:

      await Share.shareXFiles([XFile('/wrong/path')],
        text: 'text',
      );

The first time we see the exception:

PlatformException(Share failed, /wrong/path: The source file doesn't exist., null, null)

The second time, we can see:

PlatformException(Share callback error, prior share-sheet did not call back, did you await it? Maybe use non-result variant, null, null)

miquelbeltran avatar Apr 05 '24 09:04 miquelbeltran

This issue duplicates https://github.com/fluttercommunity/plus_plugins/issues/1351

miquelbeltran avatar Apr 05 '24 09:04 miquelbeltran

This exception (PlatformException(Share callback error, prior share-sheet did not call back,...) is thrown because the ShareSuccessManager is a wrong state after a failed share operation, the isCalledBack atomic boolean is set to false.

So we need to find a way to reset this state when an error occurs.

miquelbeltran avatar Apr 05 '24 09:04 miquelbeltran

This problem was introduced originally when the shareWithResult methods were implemented: https://github.com/fluttercommunity/plus_plugins/commit/0f4a193181d6e5bc73ccd39db0ecdd06bc2fb35d as the ShareSuccessManager doesn't have a way to recover from a bad state.

miquelbeltran avatar Apr 05 '24 09:04 miquelbeltran