-
Notifications
You must be signed in to change notification settings - Fork 156
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
Double execution of event listeners after remounting OTSession #271
Comments
@evillemez Thanks for filing this. The way I'm reading this, I'm thinking that the events are triggering in the second instance because the first local user has officially disconnected. To verify this, could you please mount the second instance of |
That's what I think is happening too. I'll try that test as soon as I can, it may be a little tricky to set up. |
Thanks @evillemez - please keep me updated |
I am also facing the same issue. Is there any update on it? |
@msach22, is there any update on it? |
@msach22 I'm still sure this is an issue, not finding any other explanation for the extra disconnect signals. Is there more information anyone of us, me, or @ASerga or @niraj1997 can provide here? It's a serious issue for us unfortunately, because we unmount/remount the session in the case of a party losing their network connection, or if the session/publisher/subscriber trigger an error. |
Hi @evillemez sorry for the late reply. Yes, it should be fixed in 0.12.0. Could you please confirm if after upgrading it works as expected? |
This should be fixed in opentok-react-native >= 0.12.0. Closing this issue. |
@ggoldens Not fixed yet. I'm using 0.12.1 and still not clearing the event handlers. |
I can confirm that 0.12.1 still has this issue. To elaborate a bit: I think that all unmounted sessions still "live" somewhere as @evillemez nicely says it here:
It's not limited to only one session though. Meaning that if you unmount 5 sessions and mount a new one, then any upcoming events get called 6 times. |
@TomasUhrik Are you only seeing this on iOS or on Android as well? |
This fork resolves this issue: https://github.com/naveteam/opentok-react-native |
@julianoddreis - looks like the diff is : I had a different theory on how there might be a memory leak in the native iOS SDK which is why I asked if it was for iOS or Android. |
Thanks @TomasUhrik and @julianoddreis for the extra info. @msach22 and @ggoldens - can we re-open the issue until we’re more sure it’s fixed? |
@msach22 happens on Android as well. Thanks for picking up on this so fast 👍 |
@julianoddreis Any chance you could PR your fix to this repo? |
Reopening this issue. This is going to be revisited. |
Please, is there any change on this issue? |
Same here, still running into this on |
Found this to be a very elegant solution , but to further make sure old session events do not fire, i think it will be better to just disconnect or destroy past session manually and then immediately initialise a new session |
@codeMeSid Can you describe a little more? I'm not quite following what the solution is. In our case we have unmounted the session, then mounted it again. That's supposed to trigger a disconnect/destroy of the original session, and initialize a new one - but that's not the behavior we're actually getting. When you say "disconnect or destroy the past session manually" - how exactly are you doing that? |
so now even all your existing publisher and subscribers are re-initialised |
@codeMeSid I may have missed something... Where is Is there an alternate way for us to register/unregister our event listeners instead of passing props to the @ggoldens @msach22 Is this a thing? That said - the EDIT: Adding a related question. From the current docs, there is an example of getting a ref to the session component: this.otSessionRef.current.signal({
data: '',
to: '', // optional - connectionId of connected client you want to send the signal to
type: '', // optional
}) Is it documented anywhere what the API being exposed there is? Are there any other methods we could call? Also - is this the recommended way of signaling now instead of using the |
I can still see this on 0.14.0. this is my code:
showOTSession is a functional component state and can be triggered on and off. I need to do this as I have to reload the session wit different parameters. |
Hello, we're still facing this issue with the last release. Thanks. |
Hi all, we have deployed Please let us know if it fixes the issue. Thanks again to everyone 😀 |
@enricop89 It's still happening with me and i am using version For me signal events are duplicated so it means event listener called 2 times and i have stored event listener object
I am remounting OTSession as @nicoladj77 showed above. |
Just curious of anyone is still experiencing this on the most recent versions? |
Closing this issue as it is outdated. You can open a new ticket if this issue still persists. |
I might have found the issue: when opentok-react-native/src/OTSession.js Lines 57 to 59 in 28ff333
a opentok-react-native/src/OTSession.js Lines 84 to 90 in 28ff333
when there is an error during the disconnect (eg: "the network is off"), the events are never cleaned up. Calling the events cleanup during my component cleanup manually solved the issue for me: import { removeNativeEvents } from "opentok-react-native/src/OT";
import { sanitizeSessionEvents } from "opentok-react-native/src/helpers/OTSessionHelper";
// ...
useEffect(() => {
return () => {
const events = sanitizeSessionEvents(sessionId, sessionEventHandlers);
removeNativeEvents(events);
};
}, []); but it uses non-exported functions. @TalhaAhsan : why the (got the tip from this comment: opentok/accelerator-core-js#97 (comment) ) |
@enricop89 : I tried the fix, unfortunately this doesn't solve the issue I have (reconnecting after a full disconnection) because the So there might be something else at play here preventing the component to unmount (another condition somewhere ?) I won't dig more into this as the (ugly) workaround proposed works for us in most cases (we can control the unmounting of the component embedding edit: random thought: I suppose that when the network is "off", this line here: opentok-react-native/src/OTSession.js Line 84 in 28ff333
takes "some times" to execute synchronously (waiting for a timeout on disconnect in the native code) doesn't it ? That would explain the behaviour I see. Possible solutions:
just hypothesis here, I don't know the code at all 🙈 |
@vineus ok so can you share the steps to reproduce, please? Is it just connect to a session, disconnect the network and trigger a reconnect event? |
when the component re-mounts, the events are not attached to the current |
There's still an open PR referencing this issue which hasn't been merged. I feel like this issue really should be re-opened, as it seems to still be affecting multiple teams. |
Bug Report
Current behavior
If
OTSession
is remounted, event listeners it receives from the parent component will be called twice for a time. I believe this is related to #262, but am not 100% sure.Steps to reproduce
OTSession
and defines event listeners forconnectionCreated
,streamCreated
,connectionDestroyed
andstreamDestroyed
.OTSession
only in the case where theNetInfo.isConnected
status istrue
.OTSession
OTSession
will remount and the two sides will be reconnectedconnectionDestroyed
,streamDestroyed
events fire from the original connection. On the remote side you will see astreamDestroyed
andconnectionDestroyed
event from the old connection as well.What is the current bug behavior?
Registered event handlers are firing from an instance of
OTSession
which was previously unmounted.What is the expected correct behavior?
Event handlers from old instances should be fully cleared, only triggered for the most recently mounted instance.
Other thoughts
I think part of the issue here may be shared state at the native level. If one wanted to have multiple sessions going (see #218) it is currently not possible, but another side effect of the shared state is that even in the case of only having one instance at a time in the RN layer, if a user has had to disconnect and reconnect, it is resulting in conflicting from the previously destroyed instance.
The effect of this at the app level is that it's making it impossible to tell to the difference between real disconnect events, and phantom disconnect events from a previous instance. So we have cases where two users get reconnected, but our app thinks they are disconnected because of the previous connection/streams timing out.
I've added extra checks to verify the specific stream and connection IDs, but it's not enough, because on the local side it will still see a
streamDestroyed
andconnectionDestroyed
event for the stream/connection that is actually still connected in the new instance, because the remote side still has the same stream/connection as it did before the disconnect on the local side.The text was updated successfully, but these errors were encountered: