Skip to content

Dart SDK change breaks background notifications #1119

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

Closed
gnprice opened this issue Dec 9, 2024 · 2 comments · Fixed by #1117
Closed

Dart SDK change breaks background notifications #1119

gnprice opened this issue Dec 9, 2024 · 2 comments · Fixed by #1117
Assignees

Comments

@gnprice
Copy link
Member

gnprice commented Dec 9, 2024

On upgrading to Flutter from current main, and running in release mode, the app no longer shows notifications on Android when it was in the background. This burst of error messages appears in logcat:

DartVM   E  ERROR: To access 'package:zulip/notifications/receive.dart::NotificationService' from native code, it must be annotated.
            ERROR: See https://github.com/dart-lang/sdk/blob/master/runtime/docs/compiler/aot/entry_point_pragma.md
flutter  E  [ERROR:flutter/lib/ui/dart_runtime_hooks.cc(38)] Dart Error: ERROR: To access 'package:zulip/notifications/receive.dart::NotificationService' from native code, it must be annotated.
            ERROR: See https://github.com/dart-lang/sdk/blob/master/runtime/docs/compiler/aot/entry_point_pragma.md
flutter  E  [ERROR:flutter/shell/common/shell.cc(115)] Dart Error: ERROR: To access 'package:zulip/notifications/receive.dart::NotificationService' from native code, it must be annotated.
            ERROR: See https://github.com/dart-lang/sdk/blob/master/runtime/docs/compiler/aot/entry_point_pragma.md
flutter  E  [ERROR:flutter/shell/common/shell.cc(115)] Dart Error: ERROR: To access 'package:zulip/notifications/receive.dart::NotificationService' from native code, it must be annotated.
                                                                                                    ERROR: See https://github.com/dart-lang/sdk/blob/master/runtime/docs/compiler/aot/entry_point_pragma.md

It looks like the relevant upstream commit is probably this one:
dart-lang/sdk@9b06e26
which is also the latest commit to touch that linked docs page.

AFAICT those docs don't actually say that we should need to annotate the class. We already do annotate the static method that we ask native code to call:

  @pragma('vm:entry-point')
  static Future<void> _onBackgroundMessage(FirebaseRemoteMessage message) async {

Well, at least the error message is nice and clear, though. We'll annotate the class too.

@gnprice gnprice added this to the M4: Wider beta milestone Dec 9, 2024
@gnprice gnprice self-assigned this Dec 9, 2024
@gnprice
Copy link
Member Author

gnprice commented Dec 9, 2024

This makes a good example of why it'd be valuable for us to have end-to-end testing for notifications:

gnprice added a commit to gnprice/zulip-flutter that referenced this issue Dec 9, 2024
Fixes zulip#1119.

With Flutter from main, in release mode, the app would no longer
show notifications on Android when it was in the background.
This error message appears in logcat:

```
DartVM   E  ERROR: To access 'package:zulip/notifications/receive.dart::NotificationService' from native code, it must be annotated.
            ERROR: See https://github.com/dart-lang/sdk/blob/master/runtime/docs/compiler/aot/entry_point_pragma.md
```

It looks like the relevant upstream commit is probably this one:
  dart-lang/sdk@9b06e26

AFAICT those docs don't actually say that we should need to annotate
the class.  We already do annotate the static *method* on this class
which we ask native code to call, namely `_onBackgroundMessage`.
At least the error message is nice and clear, though.
@gnprice gnprice closed this as completed in ac529bc Dec 9, 2024
shivanshsharma13 pushed a commit to shivanshsharma13/zulip-flutter that referenced this issue Dec 13, 2024
Fixes zulip#1119.

With Flutter from main, in release mode, the app would no longer
show notifications on Android when it was in the background.
This error message appears in logcat:

```
DartVM   E  ERROR: To access 'package:zulip/notifications/receive.dart::NotificationService' from native code, it must be annotated.
            ERROR: See https://github.com/dart-lang/sdk/blob/master/runtime/docs/compiler/aot/entry_point_pragma.md
```

It looks like the relevant upstream commit is probably this one:
  dart-lang/sdk@9b06e26

AFAICT those docs don't actually say that we should need to annotate
the class.  We already do annotate the static *method* on this class
which we ask native code to call, namely `_onBackgroundMessage`.
At least the error message is nice and clear, though.
@miklcct
Copy link

miklcct commented Feb 19, 2025

I have got the same issue on state restoration and adding the pragma on the class fixed the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
2 participants