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

Sharing fixes #306

Merged
merged 11 commits into from Nov 3, 2016
Merged

Sharing fixes #306

merged 11 commits into from Nov 3, 2016

Conversation

Holo-Krzysztof
Copy link

This references issue #292

The major fixes here are subscribing to NetworkConnection events so that we know when we're connected to the server instead of using Invoke with a certain time (which failed when init took more than one second) and using Singleton<T> for SharingStage, as the previous implementation was broken and an unnecessary duplication of efforts.

My previous testing showed the Sharing sample scene to work now, which wasn't the case before; I would appreciate if some other people tested and verified this to be true.

@msftclas
Copy link

Hi @Holo-Krzysztof, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.microsoft.com.

TTYL, MSBOT;

Copy link

@NeerajW NeerajW left a comment

Choose a reason for hiding this comment

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

Please sign the CLA :)


// We will register for session joined to indicate when the sharing service
// is ready for us to make room related requests.
SharingSessionTracker.Instance.SessionJoined += Instance_SessionJoined;
Copy link

Choose a reason for hiding this comment

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

Should this be removing the event handler in OnDestroy?

Copy link
Contributor

@keveleigh keveleigh Oct 26, 2016

Choose a reason for hiding this comment

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

The GitHub view is misleading. This removed line was in the SharingManagerConnected method and moved to Awake in this pull request.

Edit: Unless you're asking if this event handler should be -= in OnDestroy, then I agree haha

Copy link
Contributor

Choose a reason for hiding this comment

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

lol, yeah this actually is in the SharingManagerConneced method.

Copy link

Choose a reason for hiding this comment

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

I am asking for it to be -= in the OnDestroy :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting that it gets removed after we raise the Instance_SessionJoined event.

We also never unsubscribe to SharingManagerConnected on line 128 either.

We should probably be unsubscribing to any/all of these events whenever we call OnDestroy.

Copy link
Author

Choose a reason for hiding this comment

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

I've added a statement to unregister that handler in OnDestroy.

using UnityEngine;

namespace HoloToolkit.Sharing
{
public class SharingStage : MonoBehaviour
public class SharingStage : Singleton<SharingStage>
Copy link

Choose a reason for hiding this comment

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

Nice :)

//delay sending notification so everything is initialized properly
Invoke("SendConnectedNotification", 1);
//Invoke("SendConnectedNotification", 1);
Copy link

Choose a reason for hiding this comment

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

Remove these lines then?

@NeerajW NeerajW added the bug label Oct 24, 2016
@@ -116,18 +116,19 @@ public bool AnchorEstablished
/// </summary>
RoomManagerAdapter roomManagerCallbacks;

void Start()
void Awake()
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing this to Awake can cause issues accessing a Singleton Instance. There's no guarantee that the Singleton object will be initialized until every object's Awake is called.

Copy link
Author

Choose a reason for hiding this comment

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

Aren't scene objects loaded before the first Awake call is made?
If yes, Singleton already accounts for that by calling FindObjectOfType if the instance doesn't exist.
Otherwise I could change it to Start, but I'd need to verify that everything still works.

Copy link
Contributor

Choose a reason for hiding this comment

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

Keep in mind that the Singleton pattern is being updated due to the new input module #277

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, we found that FindObjectOfType will fail if Awake() hasn't been called yet. Since the execution order can vary, this was occasionally seen in BasicCursor.cs and raised in #246.

In addition, @HodgsonSDAS brings up a good point. The new pattern has Instance set in Awake(), so there's no guarantee it will be set in any other Awake().

@msftclas
Copy link

msftclas commented Nov 2, 2016

@Holo-Krzysztof, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, MSBOT;

Copy link
Contributor

@StephenHodgson StephenHodgson left a comment

Choose a reason for hiding this comment

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

Just one little nit. But while we're editing the ImportExportAnchorManager class anyway, could we make all the methods properties and fields explicitly private?

{
Connect();
}
}

protected void OnDestroy()
{
Instance = null;

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Extra line

@@ -116,18 +116,19 @@ public bool AnchorEstablished
/// </summary>
RoomManagerAdapter roomManagerCallbacks;

void Start()
void Awake()
Copy link
Contributor

Choose a reason for hiding this comment

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

Keep in mind that the Singleton pattern is being updated due to the new input module #277

@Holo-Krzysztof
Copy link
Author

I've moved the singleton access calls into start, WorldAnchorStore is fine in Awake, I guess.

@@ -500,7 +505,7 @@ void Export()
/// Called by the WorldAnchorTransferBatch as anchor data is available.
/// </summary>
/// <param name="data"></param>
public void WriteBuffer(byte[] data)
Copy link
Contributor

Choose a reason for hiding this comment

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

These should probably stay public, if they were already public.
Sorry, I just meant the things that weren't explicit.

@@ -509,7 +514,7 @@ public void WriteBuffer(byte[] data)
/// Called by the WorldAnchorTransferBatch when anchor exporting is complete.
/// </summary>
/// <param name="status"></param>
public void ExportComplete(SerializationCompletionReason status)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should stay public

{
get
{
return currentState.ToString();
}
}

public bool AnchorEstablished
private bool AnchorEstablished
Copy link
Contributor

Choose a reason for hiding this comment

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

should stay public

@@ -41,15 +41,15 @@ enum ImportExportState

ImportExportState currentState = ImportExportState.Start;

public string StateName
private string StateName
Copy link
Contributor

Choose a reason for hiding this comment

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

should stay public

@StephenHodgson
Copy link
Contributor

StephenHodgson commented Nov 3, 2016

Also, enum ImportExportState could be private, as well as ImportExportState currentState.

Unless someone whats to know the currentState, then it might be better as a property with a private setter.

@NeerajW NeerajW merged commit 915cd7b into microsoft:master Nov 3, 2016
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.

None yet

5 participants