-
Notifications
You must be signed in to change notification settings - Fork 856
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
flutter: Fatal Error: Callback lookup failed! #344
Comments
I have this issue too |
I'm also getting this error. It doesn't seem to cause any problem and the audio plays. |
For me it happens when audio completes. |
think this is fixed in #332 |
merged #332, released on 0.13.5, thanks @JesseScott |
I see this error in 0.14.0 version. I call setNotification(), and the correct information appears in the Command Center and Notifications on iPhone. Any attempt to click on a pause/play button in the Command Center or Notifications causes this message: Interestingly, onNotificationPlayerStateChanged() is called with the correct state despite this error message. When a file is playing from a URL, the app continues to work, but with a local file this error crashes the app. |
any solution yet? getting same error |
Same here. Anyone have a solution? |
My app works fine (is playing all local sounds), but shows this error in console shortly after every sound. |
Same here, |
Same issue here. latest version. |
Same issue here, latest version. All I'm doing is playing a sound. It happens when it completes. import 'package:audioplayers/audio_cache.dart';
import 'package:audioplayers/audioplayers.dart';
import 'package:ptp/config.dart';
class SoundService {
SoundService() {
player.loadAll(AppConfig.toneOptions.values.withoutAssetOnFront);
}
static final player = AudioCache();
void play(String path) async {
player.play(path.withoutAssetOnFront, mode: PlayerMode.LOW_LATENCY);
}
}
extension on Iterable<String> {
List<String> get withoutAssetOnFront =>
this.map((e) => e.withoutAssetOnFront).toList();
}
extension on String {
String get withoutAssetOnFront => this.replaceFirst("assets/", "");
}
|
@luanpotter please reopen |
Same issue, I am using the latest version. |
It also happens using the example on GitHub as well |
I do also get the same error. Version Where When More infos
Error log
From
onAudioChangeBackgroundEvent is null. |
Yup, getting the same error as above |
i've solved the issue by calling the "monitorNotificationStateChanges" method and passing the static function into it |
Could you please post the code of that fix, or even submit a pull request? 😊 |
just add this script
and dont forget to add the handler method to be static / top level function (outside of your class), so it could be accessed from the headless state static method
top-level function
Please note to match the return type and the argument type, otherwise it won't work |
This causes a problem in Android for me: MissingPluginException(No implementation found for method monitorNotificationStateChanges on channel xyz.luan/audioplayers) |
You can add:
|
@nohli Hi I'm another one facing this error..
but I now get [VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'toRawHandle' was called on null. not sure of what I'm doing dough..is this what you meant? I had to create an instance of AudioPlayer() as your fix was about it and not about AudioCache(). |
@vinnytwice I can give you my code which is working:
|
Same issue while using |
Tried will all the methods still the issue persists. |
@krishnatandon1208 can you share your code? |
Did you try the solutions above? They worked for me. This is what I'm using:
|
Reverting back to a release that was made 18 months ago and is 17 releases behind the current release? :-/ Why not use one of the above solutions along with the current release such as #344 (comment) ? |
I appreciate your code but for the beginners enough thing to get rid of errors in #terminal |
By downgrading 10 versions of this plugin, you just introduced at least 10 new errors to the system because all those releases in the mean time were bug fixes...it is fine enough if you get a warning in the console about this, but something completely different if you get real errors if you discard 8 months of code development from library maintainers. Be careful :) |
then you should wait for the new release....hope they fix the problem regarding this issue. |
Folks can someone confirm if this is still happening, and if so, can someone provide a simple code that reproduces this problem? I may try to take a look on this... |
yes it is repeating same problem because of new update...! |
I am using the latest release and do not have the problem when using the suggested solution as per #344 (comment) |
How is this closed and considered fixed? So we need to check for platform (because Android would crash with the "solution"). Good work! Not sure what test someone needs to reproduce. Simple small service:
Even with the fix put onto Audioplayer (which I'm not using in my small example), the error still persists:
Adding the fix (when using audioplayer instead of audiocache) also throws this error about 80% of the time (mentioned here and ignored...):
|
This isn't closed, the issue is still open 🤔 |
From a cursory glance between your code and the workaround, I can see that you're not setting the fixedPlayer when creating the
|
Doesn’t that kind of go directly to his point though? Seems from the discussions, that a simple null check would prevent a complete hard-out crash. Some sort of error-indicative return from the various calls - if necessary - could easily say ‘hey, you can’t do that without...’ rather than a hard crash with poorly documented features / object dependencies.
No crash code with proper error indicative responses is always the better choice. Crash code can equal vulnerabilities, and just feels unpolished and incomplete.
…
On Aug 12, 2020, at 9:13 AM, Rhisiart ap Gwilym ***@***.***> wrote:
How is this closed and considered fixed?
So we need to check for platform (because Android would crash with the "solution").
Fix this on every app with boilerplate code because the plugin does not simply check if a callback function is present.
Let every new user figure out by themselves where this error is coming from and how to find the fix buried in github.
Good work!
Not sure what test someone needs to reproduce.
I get that error on newest version on every .play() call. While AudioCache itself does not even expose any callback(?), so the fix does not apply.
Simple small service:
import 'dart:core';
import 'package:audioplayers/audio_cache.dart';
class Audio {
final player = AudioCache();
static final Audio _singleton = Audio._internal();
factory Audio() {
return _singleton;
}
Audio._internal();
play(String audioFile) {
player.play(audioFile);
}
}
Even with the fix put onto Audioplayer (which I'm not using in my small example), the error still persists:
import 'dart:core';
import 'dart:io';
import 'package:audioplayers/audio_cache.dart';
import 'package:audioplayers/audioplayers.dart';
class Audio {
AudioPlayer _audioPlayer;
AudioCache _player;
static final Audio _singleton = Audio._internal();
factory Audio() {
return _singleton;
}
Audio._internal() {
_player = AudioCache();
_audioPlayer = AudioPlayer();
_fixCallbackLookupFailedIssue();
}
play(String audioFile) {
_player.play(audioFile);
}
void _fixCallbackLookupFailedIssue() {
if (Platform.isIOS) {
_audioPlayer.monitorNotificationStateChanges(_audioPlayerStateChangeHandler);
}
}
void _audioPlayerStateChangeHandler(AudioPlayerState state) => null;
}
Adding the fix (when using audioplayer instead of audiocache) also throws this error about 80% of the time (mentioned here and ignored...):
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'toRawHandle' was called on null.
Receiver: null
Tried calling: toRawHandle()
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 AudioPlayer.monitorNotificationStateChanges (package:audioplayers/audioplayers.dart:354:44)
#2 Audio._fixCallbackLookupFailedIssue (package:x/utils/audio.util.dart:32:20)
#3 new Audio._internal (package:x/utils/audio.util.dart:20:5)
#4 Audio._singleton (package:x/utils/audio.util.dart:11:41)
#5 Audio._singleton (package:x/utils/audio.util.dart:11:22)
#6 new Audio (package:x/utils/audio.util.dart:14:12)
#7 _ClickableState._onTap (package:x/widgets/clickable.dart:36:5)
#8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#9 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
#10 BaseTapGestureRecognizer._checkUp <…>
From a cursory glance between your code and the #344 example, I can see that you're not setting the fixedPlayer when you're creating the AudioCache...
_audioCache = AudioCache(prefix: 'sounds/', fixedPlayer: _audioPlayer);
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
You're right, but it doesn't change much as it then runs into the toRawHandle exception as mentioned. |
Quoting my own message, if someone could provide a simple code that reproduce this, I could try giving a look, I have tried reproducing this on our example app and I am not been able to see this problem happening. |
Better still, a full repo. |
Didn't I do that? There is no error being thrown in the app itself but the log bubbles up. So it's annoying, but doesn't kill the app itself. |
Please provide a working Flutter repo that we can clone so that we reproduce the error along with |
I'm getting the same error using AudioCache.play() flutter: Fatal Error: Callback lookup failed! |
|
Hi, @xni06 I' have the same error using AudioCache.play() with audioplayers: 0.16.1. flutter: Fatal Error: Callback lookup failed! Repo for bug reproduction : Device tested : Flutter doctor output :
Have a nice day |
Thanks for the repo - perfect. Here are the steps that I took a few moments ago...
I note that your code did not have the suggested fix - did you try it before posting? |
@xni06 Your temporary fix work for me:) I hope this bug will'be fixed for the last version of this awesome package 🙂 |
@xni06 Maybe that works for AudioPlayer, but AudioCache (which is required for using assets) doesn't have monitorNotificationStateChanges. Just so that everyone is clear on this, this doesn't really crash anything, it just prints a message. |
|
BTW ensure this function is outside of Audio class. void _audioPlayerStateChangeHandler(AudioPlayerState state) => null; |
Closing this due to reports of this being fixed on newer versions. Feel free to open a new issue in case of this still happening |
console log print everytime Fatal Error: Callback lookup failed!
flutter stable channel
version audioplayers: ^0.13.3
Thanks!
The text was updated successfully, but these errors were encountered: