@@ -58,7 +58,7 @@ pub struct NodeRuntime {
58
58
pub ( crate ) click_targets : HashMap < NodeId , Vec < ClickTarget > > ,
59
59
pub ( crate ) transforms : HashMap < NodeId , DAffine2 > ,
60
60
pub ( crate ) upstream_transforms : HashMap < NodeId , DAffine2 > ,
61
- compile_cache : Option < ( u64 , Vec < Vec < NodeId > > ) > ,
61
+ graph_hash : Option < u64 > ,
62
62
canvas_cache : HashMap < Vec < LayerId > , SurfaceId > ,
63
63
}
64
64
@@ -126,7 +126,7 @@ impl NodeRuntime {
126
126
canvas_cache : HashMap :: new ( ) ,
127
127
click_targets : HashMap :: new ( ) ,
128
128
transforms : HashMap :: new ( ) ,
129
- compile_cache : None ,
129
+ graph_hash : None ,
130
130
upstream_transforms : HashMap :: new ( ) ,
131
131
}
132
132
}
@@ -154,8 +154,10 @@ impl NodeRuntime {
154
154
} ) => {
155
155
let ( result, monitor_nodes) = self . execute_network ( & path, graph, transform, viewport_resolution) . await ;
156
156
let mut responses = VecDeque :: new ( ) ;
157
- self . update_thumbnails ( & path, & monitor_nodes, & mut responses) ;
158
- self . update_upstream_transforms ( & monitor_nodes) ;
157
+ if let Some ( ref monitor_nodes) = monitor_nodes {
158
+ self . update_thumbnails ( & path, & monitor_nodes, & mut responses) ;
159
+ self . update_upstream_transforms ( & monitor_nodes) ;
160
+ }
159
161
let response = GenerationResponse {
160
162
generation_id,
161
163
result,
@@ -172,7 +174,7 @@ impl NodeRuntime {
172
174
}
173
175
}
174
176
175
- async fn execute_network < ' a > ( & ' a mut self , path : & [ LayerId ] , graph : NodeNetwork , transform : DAffine2 , viewport_resolution : UVec2 ) -> ( Result < TaggedValue , String > , MonitorNodes ) {
177
+ async fn execute_network < ' a > ( & ' a mut self , path : & [ LayerId ] , graph : NodeNetwork , transform : DAffine2 , viewport_resolution : UVec2 ) -> ( Result < TaggedValue , String > , Option < MonitorNodes > ) {
176
178
if self . wasm_io . is_none ( ) {
177
179
self . wasm_io = Some ( WasmApplicationIo :: new ( ) . await ) ;
178
180
}
@@ -204,12 +206,15 @@ impl NodeRuntime {
204
206
let font_hash_code = graph_input_hash. finish ( ) ;
205
207
graph. hash ( & mut graph_input_hash) ;
206
208
let hash_code = graph_input_hash. finish ( ) ;
209
+ log:: debug!( "Hash code: {}" , hash_code) ;
207
210
208
- if self . compile_cache . as_ref ( ) . map ( | ( hash , _ ) | * hash ) != Some ( hash_code) {
209
- self . compile_cache = None ;
211
+ if self . graph_hash != Some ( hash_code) {
212
+ self . graph_hash = None ;
210
213
}
211
214
212
- if self . compile_cache . is_none ( ) {
215
+ let mut cached_monitor_nodes = None ;
216
+
217
+ if self . graph_hash . is_none ( ) {
213
218
let scoped_network = wrap_network_in_scope ( graph, font_hash_code) ;
214
219
215
220
let monitor_nodes = scoped_network
@@ -223,18 +228,18 @@ impl NodeRuntime {
223
228
let c = Compiler { } ;
224
229
let proto_network = match c. compile_single ( scoped_network) {
225
230
Ok ( network) => network,
226
- Err ( e) => return ( Err ( e) , monitor_nodes) ,
231
+ Err ( e) => return ( Err ( e) , Some ( monitor_nodes) ) ,
227
232
} ;
228
233
229
234
assert_ne ! ( proto_network. nodes. len( ) , 0 , "No protonodes exist?" ) ;
230
235
if let Err ( e) = self . executor . update ( proto_network) . await {
231
236
error ! ( "Failed to update executor:\n {e}" ) ;
232
- return ( Err ( e) , monitor_nodes) ;
237
+ return ( Err ( e) , Some ( monitor_nodes) ) ;
233
238
}
234
239
235
- self . compile_cache = Some ( ( hash_code, monitor_nodes) ) ;
240
+ cached_monitor_nodes = Some ( monitor_nodes) ;
241
+ self . graph_hash = Some ( hash_code) ;
236
242
}
237
- let ( hash_code, monitor_nodes) = self . compile_cache . as_ref ( ) . unwrap ( ) ;
238
243
239
244
use graph_craft:: graphene_compiler:: Executor ;
240
245
@@ -246,7 +251,7 @@ impl NodeRuntime {
246
251
} ;
247
252
let result = match result {
248
253
Ok ( value) => value,
249
- Err ( e) => return ( Err ( e) , monitor_nodes . clone ( ) ) ,
254
+ Err ( e) => return ( Err ( e) , cached_monitor_nodes ) ,
250
255
} ;
251
256
252
257
if let TaggedValue :: SurfaceFrame ( SurfaceFrame { surface_id, transform : _ } ) = result {
@@ -259,7 +264,7 @@ impl NodeRuntime {
259
264
}
260
265
}
261
266
}
262
- ( Ok ( result) , monitor_nodes . clone ( ) )
267
+ ( Ok ( result) , cached_monitor_nodes )
263
268
}
264
269
265
270
/// Recomputes the thumbnails for the layers in the graph, modifying the state and updating the UI.
0 commit comments