-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
API calls on Android fail with "The player is not initialized. Call setupPlayer first." #2355
Comments
Seconded. I had this issue As mentioned it works on some android devices but not all. For me it did not work on OnePlus 10T devices. |
with no reproduction, no logs, ur best bet other than paying someone to debug your complex app for you (SWE contract rate is ~$200/hr?), is quite frankly black magic. I can vouch I've never seen this on my sentry report with my piss poor install base, so it could be your app is simply set up wrong, could be a react native bs, who knows. and if it occurs to the oneplus family of phones, too bad; u'd have to convince an unpaid maintainer to buy an oneplus 10T out of the kindness of their heart and pocket to debug this for you without any outlined steps to reproduce, which is not going to happen. |
I was merely backing up what the OP said. My app is setup correctly and I have found a workaround for the OnePlus so I'm good but I saw that others had the issue in the previous post which I referenced above. 95% of android users and all iOS do not have this issue for me. If others have it then there must be a common denominator. |
im also merely pointing out the fact this is very likely not going to be resolved based on the very limited amount of information provided and being a unique android vendor specific problem. also if you can outline what you did as an oneplus workaround it would immensely help your peer at this issue. |
I fully understand I'm not sharing much to go on wrt this bug and appreciate any attention anyone has for it. Fwiw I believe my app is set up correctly, but see #2344. I see this issue on both Android 13 and Android 14 OS. Devices include (according to Sentry):
It seems this likely happens in My app does listen to /**
* @format
*/
import {AppRegistry} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
import App from './src/App';
import {name as appName} from './app.json';
import TrackPlayer, { IOSCategoryOptions, AppKilledPlaybackBehavior } from 'react-native-track-player';
import Audio from './src/components/common/Audio';
import { QueryClient } from '@tanstack/react-query';
import AsyncStorage from '@react-native-async-storage/async-storage'
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'
import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'
import 'react-native-url-polyfill/auto';
import 'react-native-get-random-values';
import { navigationRef } from './src/components/common/Navigation';
const queryClient = new QueryClient({
defaultOptions: {
queries: {
gcTime: Infinity, // Let's hold things forever
},
},
});
const asyncStoragePersister = createAsyncStoragePersister({
storage: AsyncStorage,
key: "tanstack"
});
const NotewizeApp = () => (
<NavigationContainer ref={navigationRef}>
<PersistQueryClientProvider client={queryClient} persistOptions={{ persister: asyncStoragePersister }}>
<App/>
</PersistQueryClientProvider>
</NavigationContainer>
);
AppRegistry.registerComponent(appName, () => NotewizeApp);
async function setupTrackPlayerAndLoadModel() {
TrackPlayer.registerPlaybackService(() => require('./src/components/pages/Player/service.js'));
await TrackPlayer.setupPlayer({
iosCategoryOptions: [IOSCategoryOptions.AllowBluetoothA2DP]
});
await TrackPlayer.updateOptions({
android: {
appKilledPlaybackBehavior: AppKilledPlaybackBehavior.StopPlaybackAndRemoveNotification
},
});
await TrackPlayer.setVolume(0.5);
const chord = require("./android/app/src/main/res/raw/notewize_chord.mp3");
await TrackPlayer.add({
url: chord
});
TrackPlayer.play();
await Audio.loadModel();
}
setupTrackPlayerAndLoadModel();
|
could u monitor eg. musicservice's ondestory to confirm the service is being terminated? and perhaps get the reason why it's killed? otherwise we are just guessing at this point, i'll mention #2244 which is also related to service being killed and then initialized incorrectly. |
Hm... I guess I should ask this naive question: Is there any configuration or setup to avoid the background service? My app (it's a music teaching and learning app) doesn't need (and specifically doesn't want) to do anything audio-wise when the app is in the background. |
im afraid u used the wrong library. RNTP is specifically a music library that supports a background service (notification). you should be looking into eg. expo-av. on the other hand, all music players require a background service, which is what RNTP caters to. |
Thanks for the attention so far and sorry for the noise. I'm looking more deeply and I see this is likely the app initialization code. I am seeing failures in the startup code occasionally. And, I think these errors are only reported by clients that see this error first "Error: On Android the app must be in the foreground when setting up the player.". I will close this. |
Describe the Bug
Any API call can fail with this. I've got over 300 events of this happening in sentry. pause(), setVolume(), setRepeatMode(), and others. It would be helpful to know if this error being thrown in Sentry actually means the APi calls are failing...I can't tell.
Steps To Reproduce
I see it in the field with my customers. I don't know how to reproduce it. It seems it might be triggered by the ap pgoing to the background and then waking up, but that doesn't cause the issue on our test devices.
'
Code To Reproduce
Nope, not practical.
Replicable on Example App?
That app is wildly complicated.
Environment Info:
Real device, 4.0.0 of rntp, all sorts of android devices and OSes.
How I can Help
There's some other bug (that was closed, reopened, and then closed because team would asks for using the example app for reproduction, which is frankly often not practical). See #1636. I
The text was updated successfully, but these errors were encountered: