-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Hello, we are using THEOplayer in our project and have recently decided to enable StrictMode globally to help us catch serious issues early. After enabling it, we discovered that our player stopped working correctly. After investigation we determined that the root cause lies within the library itself. Below is a more detailed description of the problem.
When THEOplayerView is rendered inside React StrictMode, the player instance received in the onPlayerReady callback is in a broken/stale state. Properties such as player.duration permanently return -1 and never update, even after the media finishes loading. Outside of StrictMode the same code works correctly and player.duration reflects the actual media duration.
Environment
| Package | Version |
|---|---|
react-native-theoplayer |
10.10.0 |
react |
19.2.0 |
react-native (react-native-tvos) |
0.83.1 |
theoplayer (web) |
^10.10.0 |
Steps to Reproduce
- Clone the repository and navigate to the
exampledirectory. - Move all player logic out of
App.tsxinto a separate component (e.g.Player.tsx) — which is exactly what the example app already does after this change. - Wrap the component with
<StrictMode>inApp.tsx:
App.tsx
import React, { StrictMode } from 'react';
import Player from './Player';
const App = () => {
return (
<StrictMode>
<Player />
</StrictMode>
);
};
export default App;Player.tsx (relevant excerpt)
const onPlayerReady = useCallback((player: THEOplayer) => {
setPlayer(player);
player.autoplay = true;
player.source = SOURCES[0].source;
// ...
}, []);
// Later, player.duration === -1 and never changes- Run the app on iOS or Android.
- Observe that
player.durationis always-1and no player events (e.g.LOADED_METADATA,LOADED_DATA) ever fire through the storedplayerreference.
player.duration is -1 indefinitely. Player event listeners attached in onPlayerReady do not receive events. The player appears to be in an uninitialized or already-destroyed state.