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 mocking and session ending event loop models #25

Merged
merged 2 commits into from Jul 26, 2019
Merged

Fix mocking and session ending event loop models #25

merged 2 commits into from Jul 26, 2019

Conversation

@Manishearth
Copy link
Member

Manishearth commented Jul 23, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Jul 23, 2019

The latest upstream changes (presumably #26) made this pull request unmergeable. Please resolve the merge conflicts.

@Manishearth Manishearth mentioned this pull request Jul 24, 2019
Copy link
Member

asajeffrey left a comment

OK I am confused about what's going on here. Why is the headless discovery impl spawning a thread?

}
fn set_quitter(&mut self, _: Quitter) {
// Glwindow currently doesn't have any way to end its own session
// XXXManishearth add something for this that listens for the window

This comment has been minimized.

@asajeffrey

asajeffrey Jul 24, 2019

Member

Yeah, this is annoying. Glutin only has one event loop, which makes it difficult to support examples like this, where events on the servo window should go to servo, and events on the glwindow window should go to it.

/// Quit the session
fn quit(&mut self);

fn set_quitter(&mut self, quitter: Quitter);

This comment has been minimized.

@asajeffrey

asajeffrey Jul 24, 2019

Member

Hmm, this is annoying, it would be nice if we could just generate an end event for this, but that goes to script rather than the session thread. We could just use a polling+waker API, which is what Rust futures use.

We can just land this for now, perhaps with an issue to remind us to revisit it?

This comment has been minimized.

@Manishearth

Manishearth Jul 24, 2019

Author Member

The quitter is basically a glorified waker, scoped so that all it can do is send quit events

This comment has been minimized.

@asajeffrey

asajeffrey Jul 24, 2019

Member

I think we're going to need a general MainThreadWaker anyway, perhaps Quitter could just use that?

let data_ = data.clone();

thread::spawn(move || {
run_loop(receiver, data_);

This comment has been minimized.

@asajeffrey

asajeffrey Jul 24, 2019

Member

OK I am confused by this, why is HeadlessMockDiscovery spinning up a thread?

This comment has been minimized.

@Manishearth

Manishearth Jul 24, 2019

Author Member

We need to be able to request sessions to the same device multiple times. The device is longer lived -- if a session ends, the device sticks around, but if the device disconnects you have to rerun simulatedeviceconnection.

Given that simulateDeviceConnection spawns a Discovery, the model I'm following is that each Discovery is a single device (which is forever lost once disconnected, though it stays in the array as an inert Discovery object)

This comment has been minimized.

@asajeffrey

asajeffrey Jul 24, 2019

Member

Hmm, that's a different model than I was thinking of, which is that each Device object is only as long-lived as its session, so it made sense to have it owned by the SessionThread. If nothing else, that means the name isn't ideal, as Device should be ActiveDevice?

This comment has been minimized.

@Manishearth

Manishearth Jul 24, 2019

Author Member

This won't work, because you need to be able to persist mock device state between sessions.

This comment has been minimized.

@Manishearth

Manishearth Jul 24, 2019

Author Member

You're right, the Device trait is the session, and we could rename it. But we still need a separate event loop here.

}))
}
}

fn run_loop(receiver: Receiver<MockDeviceMsg>, data: Arc<Mutex<HeadlessDeviceData>>) {
while let Ok(msg) = receiver.recv() {

This comment has been minimized.

@asajeffrey

asajeffrey Jul 24, 2019

Member

I don't understand why headless discovery is using its own event loop.

@bors-servo
Copy link
Contributor

bors-servo commented Jul 24, 2019

The latest upstream changes (presumably #28) made this pull request unmergeable. Please resolve the merge conflicts.

@Manishearth Manishearth force-pushed the loopy branch 2 times, most recently from 120f39f to 37fe820 Jul 24, 2019
@asajeffrey
Copy link
Member

asajeffrey commented Jul 25, 2019

OK, at this point I'm okay with landing this and revisiting it once we've replaced SessionThread and friends by ConnectionThread.

@bors-servo
Copy link
Contributor

bors-servo commented Jul 25, 2019

The latest upstream changes (presumably #29) made this pull request unmergeable. Please resolve the merge conflicts.

@Manishearth
Copy link
Member Author

Manishearth commented Jul 25, 2019

Ready to land, waiting for the servo side of your PRs to make it first.

@Manishearth
Copy link
Member Author

Manishearth commented Jul 26, 2019

@bors-servo r=asajeffrey

@bors-servo
Copy link
Contributor

bors-servo commented Jul 26, 2019

📌 Commit eb8c81a has been approved by asajeffrey

@bors-servo
Copy link
Contributor

bors-servo commented Jul 26, 2019

Testing commit eb8c81a with merge cf974f5...

bors-servo added a commit that referenced this pull request Jul 26, 2019
Fix mocking and session ending event loop models

r? @asajeffrey
@bors-servo
Copy link
Contributor

bors-servo commented Jul 26, 2019

☀️ Test successful - checks-travis
Approved by: asajeffrey
Pushing cf974f5 to master...

@bors-servo bors-servo merged commit eb8c81a into master Jul 26, 2019
5 checks passed
5 checks passed
Travis CI - Branch Build Passed
Details
Travis CI - Pull Request Build Passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
homu Test successful
Details
bors-servo added a commit to servo/servo that referenced this pull request Jul 26, 2019
Improve session test lifecycle code

Requires servo/webxr#25

Fixes #23796, hopefully

r? @asajeffrey

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23839)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request Jul 29, 2019
GoogleVR support

Depends on #25

Not yet finished.
bors-servo added a commit to servo/servo that referenced this pull request Jul 30, 2019
Improve session test lifecycle code

Requires servo/webxr#25

Fixes #23796, hopefully

r? @asajeffrey

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23839)
<!-- Reviewable:end -->
@Manishearth Manishearth deleted the loopy branch Aug 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.