ryanheise / audio_service

Flutter plugin to play audio in the background while the screen is off.
796 stars 477 forks source link

[web] JS interop class MediaMetadata conflicts with natively supported class MediaMetadata in dart:html #574

Closed andrei-pavel closed 3 years ago

andrei-pavel commented 3 years ago

Which API doesn't behave as documented, and how does it misbehave? README.md shows that web should be supported, but when I flutter build web from the command line, I get a JS interop error.

Minimal reproduction project The example

To Reproduce (i.e. user steps, not code)

  1. Run flutter build web
  2. See error

Error messages

$ flutter build web
Running "flutter pub get" in example...                          2,920ms
Target dart2js failed: Exception: ../lib/js/media_metadata.dart:7:7:    
Error: JS interop class 'MediaMetadata' conflicts with natively supported class 'MediaMetadata' in
'dart:html'.
class MediaMetadata {
      ^
Error: Compilation failed.

Compiling lib/main.dart for the Web...                              8.1s
Exception: Failed to compile application for the Web.

Expected behavior I would have expected no error and the web directory containing generated static files.

Screenshots N/A

Runtime Environment (please complete the following information if relevant):

Flutter SDK version

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.26.0-2.0.pre.167, on Linux, locale en_GB.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Chrome - develop for the web
[✓] Android Studio
[✓] Connected device (2 available)

• No issues found!

Additional context Manifests on beta & dev flutter versions as well. Stable is not yet ready for web.

ryanheise commented 3 years ago

Does the problem manifest with flutter run?

andrei-pavel commented 3 years ago

Yes

$ flutter run -d chrome
Launching lib/main.dart on Chrome in debug mode...
../../../.pub-cache/hosted/pub.dartlang.org/audio_service-0.16.0/lib/js/media_metadata.dart:7:7: Error:
JS interop class 'MediaMetadata' conflicts with natively supported class 'MediaMetadata' in
'dart:html'.
class MediaMetadata {                                                   
      ^                                                                 
Waiting for connection from debug service on Chrome...             21.5s
Failed to compile application.
$ dart2js --version
Dart-to-JavaScript compiler (dart2js) version: 2.10.4
ryanheise commented 3 years ago

Hmm, strangely I'm not able to reproduce this:

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.25.0-8.1.pre, on Linux, locale en_AU.UTF-8)

Then flutter run -d chrome ran without error. I wonder if some libraries are being resolved differently. Here are my pubspec.lock files:

plugin pubspec.lock ``` # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: _fe_analyzer_shared: dependency: transitive description: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted version: "12.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted version: "0.40.6" archive: dependency: transitive description: name: archive url: "https://pub.dartlang.org" source: hosted version: "2.0.13" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted version: "2.5.0-nullsafety.3" audio_session: dependency: "direct main" description: name: audio_session url: "https://pub.dartlang.org" source: hosted version: "0.0.10" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted version: "2.1.0-nullsafety.3" build: dependency: transitive description: name: build url: "https://pub.dartlang.org" source: hosted version: "1.5.0" built_collection: dependency: transitive description: name: built_collection url: "https://pub.dartlang.org" source: hosted version: "4.3.2" built_value: dependency: transitive description: name: built_value url: "https://pub.dartlang.org" source: hosted version: "7.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted version: "1.1.0-nullsafety.5" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted version: "1.2.0-nullsafety.3" cli_util: dependency: transitive description: name: cli_util url: "https://pub.dartlang.org" source: hosted version: "0.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted version: "1.1.0-nullsafety.3" code_builder: dependency: transitive description: name: code_builder url: "https://pub.dartlang.org" source: hosted version: "3.5.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted version: "1.15.0-nullsafety.5" convert: dependency: transitive description: name: convert url: "https://pub.dartlang.org" source: hosted version: "2.1.1" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted version: "2.1.5" dart_style: dependency: transitive description: name: dart_style url: "https://pub.dartlang.org" source: hosted version: "1.3.9" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted version: "1.2.0-nullsafety.3" ffi: dependency: transitive description: name: ffi url: "https://pub.dartlang.org" source: hosted version: "0.1.3" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted version: "5.1.0" fixnum: dependency: transitive description: name: fixnum url: "https://pub.dartlang.org" source: hosted version: "0.10.11" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" flutter_cache_manager: dependency: "direct main" description: name: flutter_cache_manager url: "https://pub.dartlang.org" source: hosted version: "2.1.0" flutter_isolate: dependency: "direct main" description: name: flutter_isolate url: "https://pub.dartlang.org" source: hosted version: "1.0.0+14" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" flutter_web_plugins: dependency: "direct main" description: flutter source: sdk version: "0.0.0" glob: dependency: transitive description: name: glob url: "https://pub.dartlang.org" source: hosted version: "1.2.0" http: dependency: transitive description: name: http url: "https://pub.dartlang.org" source: hosted version: "0.12.1" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted version: "3.1.4" image: dependency: transitive description: name: image url: "https://pub.dartlang.org" source: hosted version: "2.1.19" intl: dependency: transitive description: name: intl url: "https://pub.dartlang.org" source: hosted version: "0.16.1" js: dependency: "direct main" description: name: js url: "https://pub.dartlang.org" source: hosted version: "0.6.3-nullsafety.3" logging: dependency: transitive description: name: logging url: "https://pub.dartlang.org" source: hosted version: "0.11.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted version: "0.12.10-nullsafety.3" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted version: "1.3.0-nullsafety.6" mockito: dependency: "direct dev" description: name: mockito url: "https://pub.dartlang.org" source: hosted version: "4.1.3" node_interop: dependency: transitive description: name: node_interop url: "https://pub.dartlang.org" source: hosted version: "1.2.0" node_io: dependency: transitive description: name: node_io url: "https://pub.dartlang.org" source: hosted version: "1.1.1" package_config: dependency: transitive description: name: package_config url: "https://pub.dartlang.org" source: hosted version: "1.9.3" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted version: "1.8.0-nullsafety.3" path_provider: dependency: transitive description: name: path_provider url: "https://pub.dartlang.org" source: hosted version: "1.6.22" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted version: "0.0.1+1" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted version: "0.0.4+3" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted version: "1.0.3" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted version: "0.0.4+1" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted version: "1.9.0" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted version: "3.1.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted version: "2.2.1" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted version: "1.0.2" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted version: "3.0.13" pub_semver: dependency: transitive description: name: pub_semver url: "https://pub.dartlang.org" source: hosted version: "1.4.4" quiver: dependency: transitive description: name: quiver url: "https://pub.dartlang.org" source: hosted version: "2.1.5" rxdart: dependency: "direct main" description: name: rxdart url: "https://pub.dartlang.org" source: hosted version: "0.25.0" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" source_gen: dependency: transitive description: name: source_gen url: "https://pub.dartlang.org" source: hosted version: "0.9.8" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted version: "1.8.0-nullsafety.4" sqflite: dependency: "direct main" description: name: sqflite url: "https://pub.dartlang.org" source: hosted version: "1.3.2+1" sqflite_common: dependency: transitive description: name: sqflite_common url: "https://pub.dartlang.org" source: hosted version: "1.0.2+1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted version: "1.10.0-nullsafety.6" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted version: "2.1.0-nullsafety.3" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted version: "1.1.0-nullsafety.3" synchronized: dependency: transitive description: name: synchronized url: "https://pub.dartlang.org" source: hosted version: "2.2.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted version: "1.2.0-nullsafety.3" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted version: "0.2.19-nullsafety.6" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted version: "1.3.0-nullsafety.5" uuid: dependency: transitive description: name: uuid url: "https://pub.dartlang.org" source: hosted version: "2.0.4" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted version: "2.1.0-nullsafety.5" watcher: dependency: transitive description: name: watcher url: "https://pub.dartlang.org" source: hosted version: "0.9.7+15" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted version: "1.7.3" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted version: "0.1.0" xml: dependency: transitive description: name: xml url: "https://pub.dartlang.org" source: hosted version: "4.5.1" yaml: dependency: transitive description: name: yaml url: "https://pub.dartlang.org" source: hosted version: "2.2.1" sdks: dart: ">=2.12.0-0.0 <3.0.0" flutter: ">=1.22.2 <2.0.0" ```
example pubspec.lock ``` # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: archive: dependency: transitive description: name: archive url: "https://pub.dartlang.org" source: hosted version: "2.0.13" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted version: "2.5.0-nullsafety.3" audio_service: dependency: "direct main" description: path: ".." relative: true source: path version: "0.16.0" audio_session: dependency: "direct main" description: name: audio_session url: "https://pub.dartlang.org" source: hosted version: "0.0.10" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted version: "2.1.0-nullsafety.3" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted version: "1.1.0-nullsafety.5" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted version: "1.2.0-nullsafety.3" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted version: "1.1.0-nullsafety.3" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted version: "1.15.0-nullsafety.5" convert: dependency: transitive description: name: convert url: "https://pub.dartlang.org" source: hosted version: "2.1.1" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted version: "2.1.5" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted version: "0.1.3" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted version: "1.2.0-nullsafety.3" ffi: dependency: transitive description: name: ffi url: "https://pub.dartlang.org" source: hosted version: "0.1.3" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted version: "5.1.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" flutter_cache_manager: dependency: transitive description: name: flutter_cache_manager url: "https://pub.dartlang.org" source: hosted version: "2.1.0" flutter_isolate: dependency: transitive description: name: flutter_isolate url: "https://pub.dartlang.org" source: hosted version: "1.0.0+14" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" flutter_tts: dependency: "direct main" description: name: flutter_tts url: "https://pub.dartlang.org" source: hosted version: "0.8.7" flutter_web_plugins: dependency: transitive description: flutter source: sdk version: "0.0.0" http: dependency: transitive description: name: http url: "https://pub.dartlang.org" source: hosted version: "0.12.1" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted version: "3.1.4" image: dependency: transitive description: name: image url: "https://pub.dartlang.org" source: hosted version: "2.1.19" intl: dependency: transitive description: name: intl url: "https://pub.dartlang.org" source: hosted version: "0.16.1" js: dependency: transitive description: name: js url: "https://pub.dartlang.org" source: hosted version: "0.6.3-nullsafety.3" just_audio: dependency: "direct main" description: name: just_audio url: "https://pub.dartlang.org" source: hosted version: "0.6.4" just_audio_platform_interface: dependency: transitive description: name: just_audio_platform_interface url: "https://pub.dartlang.org" source: hosted version: "2.0.0" just_audio_web: dependency: transitive description: name: just_audio_web url: "https://pub.dartlang.org" source: hosted version: "0.2.1" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted version: "0.12.10-nullsafety.3" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted version: "1.3.0-nullsafety.6" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted version: "1.8.0-nullsafety.3" path_provider: dependency: "direct main" description: name: path_provider url: "https://pub.dartlang.org" source: hosted version: "1.6.22" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted version: "0.0.1+1" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted version: "0.0.4+3" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted version: "1.0.3" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted version: "0.0.4+1" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted version: "1.9.0" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted version: "3.1.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted version: "2.2.1" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted version: "1.0.3" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted version: "3.0.13" rxdart: dependency: "direct main" description: name: rxdart url: "https://pub.dartlang.org" source: hosted version: "0.25.0" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted version: "1.8.0-nullsafety.4" sqflite: dependency: transitive description: name: sqflite url: "https://pub.dartlang.org" source: hosted version: "1.3.2+1" sqflite_common: dependency: transitive description: name: sqflite_common url: "https://pub.dartlang.org" source: hosted version: "1.0.2+1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted version: "1.10.0-nullsafety.6" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted version: "2.1.0-nullsafety.3" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted version: "1.1.0-nullsafety.3" synchronized: dependency: transitive description: name: synchronized url: "https://pub.dartlang.org" source: hosted version: "2.2.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted version: "1.2.0-nullsafety.3" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted version: "0.2.19-nullsafety.6" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted version: "1.3.0-nullsafety.5" uuid: dependency: transitive description: name: uuid url: "https://pub.dartlang.org" source: hosted version: "2.2.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted version: "2.1.0-nullsafety.5" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted version: "1.7.3" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted version: "0.1.0" xml: dependency: transitive description: name: xml url: "https://pub.dartlang.org" source: hosted version: "4.5.1" sdks: dart: ">=2.12.0-0.0 <3.0.0" flutter: ">=1.22.2 <2.0.0" ```

It could be interesting to compare them to your own in case there are any differences.

andrei-pavel commented 3 years ago

You're right, I must have skipped the beta when going through different channels. flutter run and flutter build work for web on the beta channel. This is good enough for me. Apologies! I'll leave it to you to close this issue if you wish. It will probably be fixed in newer flutter versions. There seems to be some effort in this direction done under https://github.com/dart-lang/sdk/issues/35084.

To answer the question, I had the same pubsec.lock with beta. I had a different pubspec.lock when running on dev channel. Some packages had slightly higher versions. Not sure how package versions are tied to flutter channels.

ryanheise commented 3 years ago

Let's leave this issue open for the time being.

It's probably that the newer dart:html library will include its own MediaMetadata interoperability class at which point we can remove audio_service's own stand-in. Probably a good time to do that will be when the new version of dart:html reaches the beta channel.

keaganhilliard commented 3 years ago

Interesting... Dart html already had support for MediaSession I just had to create an interop for functionality that didn't work in their implementation. Hopefully that actually works when this hits beta haha

ryanheise commented 3 years ago

Oh, hmm, it seems that it's already in beta now! I guess what has changed is something in the way the @JS classes get compiled that causes a conflict in newer versions.

ryanheise commented 3 years ago

Looking at it a bit more, I guess that html.MediaSession still has an issue, while html.MediaMetadata seems fine. Specifically, html.MediaSession.setActionHandler only accepts void callbacks, so we'll need to stick to the current solution. But, note that this will cause a compile conflict in dev and master, and assuming that whatever's causing that compiler conflict will eventually make its way into beta, it may be a good idea to submit an issue on dart2js.

ryanheise commented 3 years ago

@keaganhilliard , apparently the current recommendation is to not use js-interop if there is a conflicting native class, at least until they either delete the native classes (because they're known to be incomplete, and they would rather not maintain them) or some alternative way (e.g. extension methods) is made to allow developers to patch those incomplete native classes.

For more details, see: https://github.com/dart-lang/sdk/issues/42200

keaganhilliard commented 3 years ago

@ryanheise well that is not helpful at all. If I'm remembering correctly, I had to use the @JS MediaMetadata class because the artwork would not load with the built in html.MediaMetadata. So I guess we could roll back to only using the native stuff for now. It would just mean that artwork probably wouldn't work and seekTo would not work either. Less than ideal for sure. I mean we could wrap the MediaSession functions with some JavaScript and pass the functions through.

I'll take a stab at making something work.

ryanheise commented 3 years ago

The native implementation of MediaMetadata seems like it should work. Maybe there will be a trick to how the constructor parameters need to be passed in as a map, especially since nested maps are involved.

From what I can tell from the documentation, this should work:

      metadata = html.MediaMetadata(jsify({
        'album': mediaItem.album,
        'title': mediaItem.title,
        'artist': mediaItem.artist,
        'artwork': [
          {
            'src': artUri,
            'sizes': '512x512',
          },
        ],
      }));

I would also point out that the conflict only occurs with the MediaMetadata class. The way the new compiler checks work is that they only detect the conflict if you use @JS(...) where ... is a JS classname. At least for now, it seems that @JS(navigator.mediaSession) is fine since that binds to the object rather than the class, and this is not checked. So fingers crossed, there may be a way to get it working by keeping navigator.mediaSession in place but using the native MediaMetadata.

ryanheise commented 3 years ago

Aside from that, the issue I linked to above says that until this JS Interop mess is sorted out, the only guaranteed way to get it to work is to use js_util.callMethod directly.

keaganhilliard commented 3 years ago

@ryanheise Looks like this works:

    session.metadata = html.MediaMetadata({
        'album': mediaItem.album,
        'title': mediaItem.title,
        'artist': mediaItem.artist,
        'artwork': [
          {
            'src': artUri,
            'sizes': '512x512',
          },
        ],
      });

It throws an error if you jsify the map.

So we should be able to just remove the MediaMetadata class and the setter in the @JS class.

ryanheise commented 3 years ago

https://stackoverflow.com/questions/65858822/flutter-audio-service-plugin-error-js-interop-class-mediametadata-conflicts

@suragch is this affecting the beta channel now?

suragch commented 3 years ago

@ryanheise It was affecting the beta and dev channels when I tried it a couple days ago (that is, when I tried to run the app from VS Code). It worked to run and build the web app on the command line though.

ryanheise commented 3 years ago

Can you try the latest commit?

suragch commented 3 years ago

After the latest commit the MediaMetadata conflict is gone so this appears to solve the problem described in this issue.

I'm getting a silent error, but it doesn't seem to prevent audio_service from working:

Error: XMLHttpRequest error.
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 906:28                get current
packages/http/src/browser_client.dart 84:22                                       <fn>
dart-sdk/lib/async/zone.dart 1446:54                                              runUnary
dart-sdk/lib/async/future_impl.dart 150:18                                        handleValue
dart-sdk/lib/async/future_impl.dart 708:44                                        handleValueCallback
dart-sdk/lib/async/future_impl.dart 737:13                                        _propagateToListeners
dart-sdk/lib/async/future_impl.dart 532:7                                         [_complete]
dart-sdk/lib/async/stream_pipe.dart 61:11                                         _cancelAndValue
dart-sdk/lib/async/stream.dart 1302:7                                             <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 324:14  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 329:39  dcall
dart-sdk/lib/html/dart2js/html_dart2js.dart 37307:58                              <fn>
    at Object.createErrorWithStack (http://localhost:53556/dart_sdk.js:5310:12)
    at Object._rethrow (http://localhost:53556/dart_sdk.js:38850:16)
    at async._AsyncCallbackEntry.new.callback (http://localhost:53556/dart_sdk.js:38844:13)
    at Object._microtaskLoop (http://localhost:53556/dart_sdk.js:38676:13)
    at _startMicrotaskLoop (http://localhost:53556/dart_sdk.js:38682:13)
    at http://localhost:53556/dart_sdk.js:34209:9

This might me something related to my server or some other aspect of my client setup. I'll open a new issue if I can isolate it.

ryanheise commented 3 years ago

Maybe CORS related?

suragch commented 3 years ago

Very well could be. I had an earlier XMLHttpRequest error that I thought I had fixed by adjusting CORS headers on the server. I'll look into that some more.

keaganhilliard commented 3 years ago

There was a CORS issue with the service worker caching. Don't know if that's what you are seeing here, but when you set the art uri for the MediaMetadata the service worker attempts to cache the image and I've never seen it actually work. It doesn't seem to have any ill effects other than the silent error.

ryanheise commented 3 years ago

@keaganhilliard does the artwork in the example show for you? For me it doesn't, although it used to show, at least for Chrome on desktop and Android.

keaganhilliard commented 3 years ago

It was working when I tried it with the code I posted above. Maybe we should remove the interop setter? This was the issue that caused me to create the JS interop for the Metadata in the first place.

ryanheise commented 3 years ago

My mistake, the notification does seem to be working in the latest commit, it is only the Image widget within the app's UI that isn't loading.

ryanheise commented 3 years ago

@andrei-pavel , @suragch , @keaganhilliard , can you confirm whether the latest commit to master works for you? I will try to push out a release once I'm confident this hasn't broken anything.

suragch commented 3 years ago

I tested the most resent commit. I think it works. I say "think" because I was getting some crashes at first but then I wasn't able to reliably reproduce them. In my last couple tries I haven't gotten any crashes. At any rate, none of the crashes were related to a conflict with MediaMetadata.

Regarding artwork not loading, I'm wondering if this is a problem outside of audio_service. I'm handling artwork directly with cached_network_image and it also isn't loading them when I start chrome from VS Code (but they load ok when I start Chrome from the terminal).

I'd say you can go ahead and publish a release, close this issue, and open a new one if any other problems come up related to web.

ryanheise commented 3 years ago

Were the crashes pointing to a line of code in audio_service? Some other changes I worked on recently may have introduced a crash, or at least there is one that I'm aware of which I fixed this morning. It affected macOS and web if the audio service was started a second time, so you might just want to test that you are able to start and stop the service multiple times.

The image widget not loading does seem to be an unrelated issue, and possibly is the service worker issue @keaganhilliard referred to earlier.

I'll leave this issue open for let's say another 8 hours and if no further crashes are reported, I'll make a release.

suragch commented 3 years ago

The crashes were related to stopping and restarting audio_service but I don't recall if there was a particular line number referenced. I think it was related to the cancel or onCancel method if I recall correctly. I was getting ready to post the stack trace but then the error wouldn't return.

On Thu, Jan 28, 2021 at 12:54 PM ryanheise notifications@github.com wrote:

Were the crashes pointing to a line of code in audio_service? Some other changes I worked on recently may have introduced a crash, or at least there is one that I'm aware of which I fixed this morning. It affected macOS and web if the audio service was started a second time, so you might just want to test that you are able to start and stop the service multiple times.

The image widget not loading does seem to be an unrelated issue, and possibly is the service worker issue @keaganhilliard https://github.com/keaganhilliard referred to earlier.

I'll leave this issue open for let's say another 8 hours and if no further crashes are reported, I'll make a release.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ryanheise/audio_service/issues/574#issuecomment-768798834, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOSWPESPOMS7QCIYNN547DS4DUX7ANCNFSM4VQOKYIA .

ryanheise commented 3 years ago

This fix has now been published in release 0.16.2.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with audio_service.