@@ -19,7 +19,7 @@ pub(crate) struct WinitApp {
19
19
pub ( crate ) window_state : WindowStateHandle ,
20
20
pub ( crate ) cef_context : cef:: Context < cef:: Initialized > ,
21
21
pub ( crate ) window : Option < Arc < Window > > ,
22
- cef_schedule : Instant ,
22
+ cef_schedule : Option < Instant > ,
23
23
}
24
24
25
25
impl WinitApp {
@@ -28,20 +28,23 @@ impl WinitApp {
28
28
window_state,
29
29
cef_context,
30
30
window : None ,
31
- cef_schedule : Instant :: now ( ) ,
31
+ cef_schedule : Some ( Instant :: now ( ) ) ,
32
32
}
33
33
}
34
34
}
35
35
36
36
impl ApplicationHandler < CustomEvent > for WinitApp {
37
37
fn about_to_wait ( & mut self , event_loop : & ActiveEventLoop ) {
38
38
let timeout = Instant :: now ( ) + Duration :: from_millis ( 10 ) ;
39
- let wait_until = timeout. min ( self . cef_schedule ) ;
39
+ let wait_until = timeout. min ( self . cef_schedule . unwrap_or ( timeout ) ) ;
40
40
event_loop. set_control_flow ( ControlFlow :: WaitUntil ( wait_until) ) ;
41
41
}
42
42
43
43
fn new_events ( & mut self , _event_loop : & ActiveEventLoop , _cause : StartCause ) {
44
- if Instant :: now ( ) > self . cef_schedule {
44
+ if let Some ( schedule) = self . cef_schedule
45
+ && schedule < Instant :: now ( )
46
+ {
47
+ self . cef_schedule = None ;
45
48
self . cef_context . work ( ) ;
46
49
}
47
50
}
@@ -78,7 +81,7 @@ impl ApplicationHandler<CustomEvent> for WinitApp {
78
81
}
79
82
}
80
83
CustomEvent :: ScheduleBrowserWork ( instant) => {
81
- self . cef_schedule = instant;
84
+ self . cef_schedule = Some ( instant) ;
82
85
}
83
86
}
84
87
}
0 commit comments