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

[Bug report] Change callback is being triggered multiple times upon a single media insert or update #1219

Closed
ibrahimEltayfe opened this issue Nov 3, 2024 · 2 comments
Labels
Sort: Out of support This issue is beyond the scope of this plugin

Comments

@ibrahimEltayfe
Copy link

Version

^3.6.1

Platforms

Android

Device Model

Realme 11 pro 5G - Android 11

flutter info

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.0, on macOS 14.1.2 23B92 darwin-x64, locale en-EG)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.90.2)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!

How to reproduce?

The callback is triggered twice for "update" events and four times for "insert" events.

      PhotoManager.addChangeCallback(changeNotify);
      PhotoManager.startChangeNotify();
void changeNotify(MethodCall call) {
   print("CHANGED");
   print(call.toString());
}
Record_2024-11-03-14-29-29.mp4

Logs

CHANGED
MethodCall(change, {mediaType: 3, id: 1000096381, type: insert, uri: content://media/external/video/media/1000096381, platform: android, galleryId: 1028075469})

CHANGED
MethodCall(change, {mediaType: 3, id: 1000096381, type: insert, uri: content://media/external/video/media/1000096381, platform: android, galleryId: 1028075469})

CHANGED
MethodCall(change, {mediaType: 3, id: 1000096381, type: insert, uri: content://media/external/video/media/1000096381, platform: android, galleryId: 1028075469})

CHANGED
MethodCall(change, {mediaType: 3, id: 1000096381, type: insert, uri: content://media/external/video/media/1000096381, platform: android, galleryId: 1028075469})

Example code (optional)

class PhotoScreen extends StatefulWidget {
  @override
  _PhotoScreenState createState() => _PhotoScreenState();
}

class _PhotoScreenState extends State<PhotoScreen> {
  @override
  void initState() {
    super.initState();
    PhotoManager.addChangeCallback(changeNotify);
    PhotoManager.startChangeNotify();
  }

  @override
  void dispose() {
    PhotoManager.removeChangeCallback(changeNotify);
    PhotoManager.stopChangeNotify();
    super.dispose();
  }

  void changeNotify(MethodCall call) {
    print("CHANGED: ${call.toString()}");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Photo Manager')),
      body: Center(child: Text('Listening for changes...')),
    );
  }
}


### Contact

_No response_
@fluttercandies-dev
Copy link

AI Summary: The changeNotify callback is triggered multiple times (twice for updates, four times for inserts) for a single media insert or update event on Android. This indicates a potential issue with the PhotoManager package's change notification mechanism, causing duplicate notifications.

@AlexV525
Copy link
Member

AlexV525 commented Nov 3, 2024

If you are still seeing multiple calls using the unmodified example of this library, that would be the problem of the device, otherwise we should look into it.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2024
@AlexV525 AlexV525 added Sort: Out of support This issue is beyond the scope of this plugin and removed Sort: BUG Platform: Android Status: Need more info await triage Automation: triage Triaged automatically by our bot. labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sort: Out of support This issue is beyond the scope of this plugin
Projects
None yet
Development

No branches or pull requests

3 participants