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

Handle cancelAnimationFrame() when called within a requestAnimationFr… #26491

Merged
merged 1 commit into from May 13, 2020

Conversation

@huangjiahua
Copy link

huangjiahua commented May 12, 2020

…ame() callback

In order to handle cancelAnimationFrame() in the callback, the raf_callback_list is moved to
current_raf_callback_list, and each callback is cloned in the iteration of current_raf_callback_list to avoid "borrowed twice".


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #26251
  • There are tests for these changes OR
  • These changes do not require tests because ___
@jdm
Copy link
Member

jdm commented May 12, 2020

@Manishearth
Copy link
Member

Manishearth commented May 12, 2020

@bors-servo r+

thanks!

@bors-servo
Copy link
Contributor

bors-servo commented May 12, 2020

📌 Commit 85c18cb has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented May 12, 2020

Testing commit 85c18cb with merge 9261cfb...

bors-servo added a commit that referenced this pull request May 12, 2020
Handle cancelAnimationFrame() when called within a requestAnimationFr…

…ame() callback

<!-- Please describe your changes on the following line: -->
In order to handle `cancelAnimationFrame()` in the callback, the `raf_callback_list` is moved to
`current_raf_callback_list`, and each callback is cloned in the iteration of `current_raf_callback_list` to avoid "borrowed twice".

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #26251

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@Manishearth
Copy link
Member

Manishearth commented May 12, 2020

Would be nice if we could add a test for this behavior. I might do that later.

@Manishearth
Copy link
Member

Manishearth commented May 12, 2020

@@ -395,7 +398,10 @@ impl XRSession {
// Step 3: XXXManishearth handle inline session

// Step 4-5
let mut callbacks = mem::replace(&mut *self.raf_callback_list.borrow_mut(), vec![]);
mem::replace(

This comment has been minimized.

Copy link
@Manishearth

Manishearth May 12, 2020

Member

I think here we should instead just swap current and raf_callback_list (asserting that current is empty), and after the for loop we should clear current

Something like

let mut current = self.current_raf_callback_list.borrow_mut();
assert!(current.is_empty());
mem::swap(&mut *self.raf_callback_list.borrow_mut(), &mut *current);
drop(current);
.....

*self.current_raf_callback_list.borrow_mut() = vec![];

This comment has been minimized.

Copy link
@Manishearth

Manishearth May 12, 2020

Member

This basically ensures we don't hold on to RAF callbacks longer than necessary

This comment has been minimized.

Copy link
@huangjiahua

huangjiahua May 12, 2020

Author

OK! Is that drop necessary?

This comment has been minimized.

Copy link
@Manishearth

Manishearth May 12, 2020

Member

Yes, because otherwise the guard will be borrowed for too long. You can also do this by inserting an enclosing scope.

@bors-servo
Copy link
Contributor

bors-servo commented May 12, 2020

💔 Test failed - status-taskcluster

@Manishearth
Copy link
Member

Manishearth commented May 12, 2020

Nice, this makes us pass some tests

  ▶ Unexpected subtest result in /webxr/xrSession_cancelAnimationFrame.https.html:
  └ PASS [expected FAIL] XRSession requestAnimationFrame callbacks can be unregistered with cancelAnimationFrame for immersive sessions
  ▶ Unexpected subtest result in /webxr/xrSession_cancelAnimationFrame.https.html:
  └ PASS [expected FAIL] XRSession requestAnimationFrame callbacks can be unregistered with cancelAnimationFrame for non-immersive sessions
@Manishearth
Copy link
Member

Manishearth commented May 12, 2020

You'll also need to update test expectations for those two listed tests. Run ./mach test-wpt /webxr/xrSession_cancelAnimationFrame.https.html --log-raw log and then ./mach update-wpt log.

@Manishearth
Copy link
Member

Manishearth commented May 13, 2020

Hmm, we should not be getting a crash with that test.

@Manishearth
Copy link
Member

Manishearth commented May 13, 2020

Tested it locally, I'm not getting a crash.

Just delete tests/wpt/metadata/webxr/xrSession_cancelAnimationFrame.https.html.ini and push, we can land it then. Be sure to squash your commits!

@huangjiahua
Copy link
Author

huangjiahua commented May 13, 2020

OK. It seems that I use a system with no GUI to run these tests.

@huangjiahua huangjiahua force-pushed the huangjiahua:fix branch from 78a6c4f to c253ad8 May 13, 2020
@Manishearth
Copy link
Member

Manishearth commented May 13, 2020

@bors-servo r+

servo should be able to run headless just fine, but yeah there can be weird GL issues

@bors-servo
Copy link
Contributor

bors-servo commented May 13, 2020

📌 Commit c253ad8 has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented May 13, 2020

Testing commit c253ad8 with merge b2a6928...

@bors-servo
Copy link
Contributor

bors-servo commented May 13, 2020

☀️ Test successful - status-taskcluster
Approved by: Manishearth
Pushing b2a6928 to master...

@bors-servo bors-servo merged commit b2a6928 into servo:master May 13, 2020
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
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.

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