mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Fix GC borrow hazard in XRSession::UpdateTargetFrameRate (#33929)
* Fix GC borrow hazard in XRSession::UpdateTargetFrameRate Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> * Limit borrow scope Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> --------- Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
This commit is contained in:
parent
01c9ecfe01
commit
78d48ae2fb
1 changed files with 15 additions and 13 deletions
|
@ -1031,21 +1031,23 @@ impl XRSessionMethods for XRSession {
|
|||
comp: InRealm,
|
||||
can_gc: CanGc,
|
||||
) -> Rc<Promise> {
|
||||
let mut session = self.session.borrow_mut();
|
||||
let supported_frame_rates = session.supported_frame_rates();
|
||||
let promise = Promise::new_in_current_realm(comp, can_gc);
|
||||
|
||||
if self.mode == XRSessionMode::Inline ||
|
||||
supported_frame_rates.is_empty() ||
|
||||
self.ended.get()
|
||||
{
|
||||
promise.reject_error(Error::InvalidState);
|
||||
return promise;
|
||||
}
|
||||
let session = self.session.borrow();
|
||||
let supported_frame_rates = session.supported_frame_rates();
|
||||
|
||||
if !supported_frame_rates.contains(&*rate) {
|
||||
promise.reject_error(Error::Type("Provided framerate not supported".into()));
|
||||
return promise;
|
||||
if self.mode == XRSessionMode::Inline ||
|
||||
supported_frame_rates.is_empty() ||
|
||||
self.ended.get()
|
||||
{
|
||||
promise.reject_error(Error::InvalidState);
|
||||
return promise;
|
||||
}
|
||||
|
||||
if !supported_frame_rates.contains(&*rate) {
|
||||
promise.reject_error(Error::Type("Provided framerate not supported".into()));
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
|
||||
*self.update_framerate_promise.borrow_mut() = Some(promise.clone());
|
||||
|
@ -1075,7 +1077,7 @@ impl XRSessionMethods for XRSession {
|
|||
}),
|
||||
);
|
||||
|
||||
session.update_frame_rate(*rate, sender);
|
||||
self.session.borrow_mut().update_frame_rate(*rate, sender);
|
||||
|
||||
promise
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue