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

fix TypeError: Cannot read property enableMicrophone of undefined error (fixes #394) #395

Closed
wants to merge 5 commits into from
Closed

Conversation

cvan
Copy link
Contributor

@cvan cvan commented May 17, 2018

No description provided.

@cvan cvan requested a review from brianpeiris May 17, 2018 21:38
@cvan cvan self-assigned this May 17, 2018
Copy link
Contributor

@brianpeiris brianpeiris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good but I would also fix toggleFreeze while you're at it, since it occurs for the same reason.

https://github.com/mozilla/hubs/blob/master/src/components/freeze-controller.js#L20

@cvan
Copy link
Contributor Author

cvan commented May 21, 2018

@brianpeiris 👍 thanks, good idea. updated. let me know!

@@ -273,16 +273,22 @@ const onReady = async () => {
mediaStream.removeTrack(track);
}
}
NAF.connection.adapter.setLocalMediaStream(mediaStream);
if (NAF.connection.adapter && NAF.connection.adapter.setLocalMediaStream) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be simplified to check only NAF.connection.adapter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we wanted to check for setLocalMediaStream specifically, in case we were ever using anything other than naf-janus-adapter. setLocalMediaStream is special to our adapter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, yeah, that's along what I thought

},

// Currently unused
unblock(clientId) {
NAF.connection.adapter.unblock(clientId);
NAF.connection.entities.completeSync(clientId);
if (NAF.connection) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know if we can expect NAF.connection to always be a truthy property?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, NAF.connection is always a NetworkConnection object, it's defined immediately when you reference networked-aframe

}
if (NAF.connection.entities) {
NAF.connection.entities.completeSync(clientId);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably, guarding this block/unblock code is a bit too overzealous, since you can (currently) only ever run this code if there are avatars in the room, and that's only possible if an adapter has been defined.

I would remove the NAF.connection guard though, since that is always defined, as I mentioned above.

Copy link
Contributor Author

@cvan cvan May 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, thanks! adjusted

src/hub.js Outdated
screenEntity.setAttribute("visible", sharingScreen);
});

document.body.addEventListener("blocked", ev => {
NAF.connection.entities.removeEntitiesOfClient(ev.detail.clientId);
if (NAF.connection.entities) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it should be safe to remove this check?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, entities is also always defined.

@@ -37,6 +37,10 @@ AFRAME.registerComponent("networked-video-player", {
document.body.appendChild(container);
}

if (!NAF.connection.adapter || !NAF.connection.adapter.getMediaStream) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unnecessary. connection.adapter should definitely be defined at this point, since we wait for nafConnected above.
Also, getMediaStream should definitely be defined if adapter is.
Also not sure how I feel about returning silently if this condition occurred, I'd rather it fail loudly, if it does ever fail.

Copy link
Contributor

@brianpeiris brianpeiris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@brianpeiris
Copy link
Contributor

Gonna push these commits in #804

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants