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

Error with just_audio_web #1326

Closed
maknon opened this issue Sep 13, 2024 · 8 comments · Fixed by #1329
Closed

Error with just_audio_web #1326

maknon opened this issue Sep 13, 2024 · 8 comments · Fixed by #1329
Assignees
Labels
1 backlog bug Something isn't working

Comments

@maknon
Copy link

maknon commented Sep 13, 2024

Which API doesn't behave as documented, and how does it misbehave?
Start getting errors while building web version of my app

Minimal reproduction project
The example

To Reproduce (i.e. user steps, not code)
Build the web version of the example in:
https://github.com/ryanheise/just_audio/blob/minor/just_audio/example/lib/main.dart

Error messages

Compiling lib\main.dart for the Web...                             10.4s
Target dart2js failed: ProcessException: Process exited abnormally with exit code 1:
../../AppData/Local/Pub/Cache/hosted/pub.dev/just_audio_web-0.4.12/lib/just_audio_web.dart:120:11:
Error: Function converted via 'toJS' contains invalid types in its function signature: 'Null Function(*dynamic*)'.
        }.toJS);
          ^
../../AppData/Local/Pub/Cache/hosted/pub.dev/just_audio_web-0.4.12/lib/just_audio_web.dart:125:11:
Error: Function converted via 'toJS' contains invalid types in its function signature: 'Null Function(*dynamic*)'.
        }.toJS);
          ^
../../AppData/Local/Pub/Cache/hosted/pub.dev/just_audio_web-0.4.12/lib/just_audio_web.dart:130:11:
Error: Function converted via 'toJS' contains invalid types in its function signature: '*Future<Null>* Function(*dynamic*)'.
        }.toJS);
          ^
../../AppData/Local/Pub/Cache/hosted/pub.dev/just_audio_web-0.4.12/lib/just_audio_web.dart:136:11:
Error: Function converted via 'toJS' contains invalid types in its function signature: 'Null Function(*dynamic*)'.
        }.toJS);
          ^
../../AppData/Local/Pub/Cache/hosted/pub.dev/just_audio_web-0.4.12/lib/just_audio_web.dart:141:11:
Error: Function converted via 'toJS' contains invalid types in its function signature: 'Null Function(*dynamic*)'.
        }.toJS);
          ^
../../AppData/Local/Pub/Cache/hosted/pub.dev/just_audio_web-0.4.12/lib/just_audio_web.dart:146:11:
Error: Function converted via 'toJS' contains invalid types in its function signature: 'Null Function(*dynamic*)'.
        }.toJS);
          ^
../../AppData/Local/Pub/Cache/hosted/pub.dev/just_audio_web-0.4.12/lib/just_audio_web.dart:151:11:
Error: Function converted via 'toJS' contains invalid types in its function signature: 'Null Function(*dynamic*)'.
        }.toJS);
          ^
../../AppData/Local/Pub/Cache/hosted/pub.dev/just_audio_web-0.4.12/lib/just_audio_web.dart:157:11:
Error: Function converted via 'toJS' contains invalid types in its function signature: 'Null Function(*dynamic*)'.
        }.toJS);
          ^
../../AppData/Local/Pub/Cache/hosted/pub.dev/just_audio_web-0.4.12/lib/just_audio_web.dart:162:11:
Error: Function converted via 'toJS' contains invalid types in its function signature: 'Null Function(*dynamic*)'.
        }.toJS);
          ^
Error: Compilation failed.
  Command: E:\Support\flutter\bin\cache\dart-sdk\bin\dart.exe E:\Support\flutter\bin\cache\dart-sdk\bin\snapshots\dart2js.dart.snapshot --platform-binaries=E:\Support\flutter\bin\cache\flutter_web_sdk\kernel --invoker=flutter_tool -Ddart.vm.product=true -DFLUTTER_WEB_AUTO_DETECT=false -DFLUTTER_WEB_USE_SKIA=true -DFLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/059e4e6d8ff6de39c29441c53e949bfb0bf17972/ --native-null-assertions --no-source-maps -o C:\Users\ias12\Desktop\untitled\.dart_tool\flutter_build\a4603cca5b796a7858700a1b566311b4\app.dill --packages=C:\Users\ias12\Desktop\untitled\.dart_tool\package_config.json --cfe-only C:\Users\ias12\Desktop\untitled\.dart_tool\flutter_build\a4603cca5b796a7858700a1b566311b4\main.dart
#0      RunResult.throwException (package:flutter_tools/src/base/process.dart:122:5)
#1      _DefaultProcessUtils.run (package:flutter_tools/src/base/process.dart:389:19)
<asynchronous suspension>
#2      Dart2JSTarget.build (package:flutter_tools/src/build_system/targets/web.dart:202:5)
<asynchronous suspension>
#3      _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:891:9)
<asynchronous suspension>
#4      Future.wait.<anonymous closure> (dart:async/future.dart:520:21)
<asynchronous suspension>
#5      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:829:32)
<asynchronous suspension>
#6      Future.wait.<anonymous closure> (dart:async/future.dart:520:21)
<asynchronous suspension>
#7      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:829:32)
<asynchronous suspension>
#8      FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:651:16)
<asynchronous suspension>
#9      WebBuilder.buildWeb (package:flutter_tools/src/web/compile.dart:92:34)
<asynchronous suspension>
#10     BuildWebCommand.runCommand (package:flutter_tools/src/commands/build_web.dart:230:5)
<asynchronous suspension>
#11     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1450:27)
<asynchronous suspension>
#12     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#13     CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#14     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:421:9)
<asynchronous suspension>
#15     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#16     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:364:5)
<asynchronous suspension>
#17     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:130:9)
<asynchronous suspension>
#18     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#19     main (package:flutter_tools/executable.dart:94:3)
<asynchronous suspension>

Error: Failed to compile application for the Web.

Expected behavior
compiling without errors

Screenshots
NA

Desktop (please complete the following information):

  • OS: Win 11
  • Browser: Edge latest

Smartphone (please complete the following information):
NA

Flutter SDK version

[√] Flutter (Channel beta, 3.26.0-0.1.pre, on Microsoft Windows [Version 10.0.22631.4169], locale en-US)
    • Flutter version 3.26.0-0.1.pre on channel beta at E:\Support\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee624bc4fd (2 days ago), 2024-09-10 17:41:06 -0500
    • Engine revision 059e4e6d8f
    • Dart version 3.6.0 (build 3.6.0-216.1.beta)
    • DevTools version 2.39.0

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

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Users\ias12\AppData\Local\Android\sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: C:\Users\ias12\AppData\Local\Programs\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
    • All Android licenses accepted.

[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.3)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.11.35303.130
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2024.2)
    • Android Studio at C:\Users\ias12\AppData\Local\Programs\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 21.0.3+-12282718-b509.11)

[√] IntelliJ IDEA Community Edition (version 2024.3)
    • IntelliJ at C:\Users\ias12\AppData\Local\Programs\IntelliJ IDEA Community Edition
    • Flutter plugin version 81.1.3
    • Dart plugin version 243.12818.47

[√] Connected device (2 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22631.4169]
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 128.0.2739.67

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

! Doctor found issues in 1 category.

Additional context
it was working at one point of time but not sure which update break all of this

@maknon maknon added 1 backlog bug Something isn't working labels Sep 13, 2024
@mikefaille
Copy link

mikefaille commented Sep 18, 2024

I can reproduce this problem switching from :

    • Flutter version 3.24.3 on channel stable at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (7 days ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

to

    • Flutter version 3.26.0-0.1.pre on channel beta at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee624bc4fd (7 days ago), 2024-09-10 17:41:06 -0500
    • Engine revision 059e4e6d8f
    • Dart version 3.6.0 (build 3.6.0-216.1.beta)
    • DevTools version 2.39.0

using :
flutter_widget_from_html: ^0.15.2

@ryanheise
Copy link
Owner

I don't use the beta version of Flutter, but I would guess it may help to add explicit type annotations to parts of the plugin that look like this:

        (event) {
          _durationCompleter?.completeError(_audioElement.error!);
        }.toJS);

So replacing (event) by (Event event). I wouldn't be able to test it for you, though. Would anyone like to try this on their end?

@SleepySquash
Copy link
Contributor

@ryanheise,

Would anyone like to try this on their end?

This fixes the issue on my end. Also ended event listener callback is marked async, which should be replaced with a sync function (there's nothing async going on inside it after all):

_audioElement.addEventListener(
    'ended',
    (Event event) {
      _currentAudioSourcePlayer?.complete();
    }.toJS);

@ryanheise
Copy link
Owner

Thanks for testing that. Would you be interested in contributing that change as a pull request, or would you prefer me to replicate that change?

@SleepySquash
Copy link
Contributor

@ryanheise, sorry for a delayed response - yep, sure, no problem! I've opened and prepared a PR: #1329
If there's anything else I should do with the PR, please, let me know.

@SergeBerwert
Copy link

I experience the same issue but only on the build server and not on the local machine. I have no idea why. Both have the same flutter/dart version.

@ryanheise
Copy link
Owner

Thanks to @SleepySquash 's pull request and @maknon for reporting, this is now merged and released on pub.dev. Use flutter pub upgrade to pull the new version into your project.

Copy link

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 just_audio.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 backlog bug Something isn't working
Projects
None yet
5 participants