Commit ec127c4
authored
Share
# Objective
- Previously, we would build the sources up to 3 times with different
options: once for the regular asset server, once for the asset
processor, and once for the asset processor's internal asset server.
- This is a step towards #21758 (since now adding a source to this
shared `AssetSources` will be reflected in all the uses.
## Solution
1) Skip all the hot-reloading polling if `watch_for_changes` is false.
If we don't do this, sharing the sources between the asset server and
the processor-internal asset server will result in two tasks consuming
asset events, so the regular asset server will miss asset events.
2) Move the state of the asset processor into a separate struct that we
then Arc. We need to be able to gate the processed asset reader, but we
can't create an asset processor without the sources. So instead we allow
ourselves to create the state first, so that we can gate on that state,
and then create the processor with that state.
3) Split the processed reader into a gated and an ungated form. The gate
first blocks on the processor being done initialized, followed by gating
on the per-asset lock. However the asset processor needs to iterate
through all the directories in order to finish initializing. So just
unconditionally gating doesn't work - we hit a deadlock. So we provide
access to the ungated processed reader, so that the processor can use
that to initialize its state.
4) Finally do the sharing!
One thing I'm starting in this PR is making things more private. For
example, it's not clear why `ProcessorGatedReader` was `pub`. I've also
made `AssetSources::gate_on_processor` no longer `pub`. This does mean
that users can no longer initialize their own `AssetServer` properly
(e.g., gated on the processor), but I don't think we should really
support this - our focus should be on the `AssetServer` initialized by
`AssetPlugin`, not hypothetical uses where someone wants to insert their
own `AssetServer`.
## Testing
- CIAssetSources between the AssetServer, the asset processor, and the asset processor's internal asset server. (#21763)1 parent 4809a3c commit ec127c4
File tree
6 files changed
+243
-94
lines changed- crates/bevy_asset/src
- io
- processor
- server
- release-content/migration-guides
6 files changed
+243
-94
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
| 20 | + | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | 34 | | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 38 | | |
52 | 39 | | |
53 | 40 | | |
54 | 41 | | |
55 | 42 | | |
56 | 43 | | |
57 | 44 | | |
58 | | - | |
| 45 | + | |
59 | 46 | | |
60 | 47 | | |
61 | 48 | | |
| |||
65 | 52 | | |
66 | 53 | | |
67 | 54 | | |
68 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
69 | 59 | | |
70 | 60 | | |
71 | 61 | | |
| |||
75 | 65 | | |
76 | 66 | | |
77 | 67 | | |
78 | | - | |
| 68 | + | |
79 | 69 | | |
80 | 70 | | |
81 | 71 | | |
| |||
85 | 75 | | |
86 | 76 | | |
87 | 77 | | |
88 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
89 | 82 | | |
90 | 83 | | |
91 | 84 | | |
| |||
99 | 92 | | |
100 | 93 | | |
101 | 94 | | |
102 | | - | |
| 95 | + | |
103 | 96 | | |
104 | 97 | | |
105 | 98 | | |
| |||
110 | 103 | | |
111 | 104 | | |
112 | 105 | | |
113 | | - | |
| 106 | + | |
114 | 107 | | |
115 | 108 | | |
116 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
184 | 189 | | |
185 | 190 | | |
186 | 191 | | |
| |||
386 | 391 | | |
387 | 392 | | |
388 | 393 | | |
389 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
390 | 400 | | |
391 | 401 | | |
392 | 402 | | |
| |||
425 | 435 | | |
426 | 436 | | |
427 | 437 | | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
428 | 445 | | |
429 | 446 | | |
430 | 447 | | |
| |||
560 | 577 | | |
561 | 578 | | |
562 | 579 | | |
563 | | - | |
| 580 | + | |
564 | 581 | | |
565 | | - | |
| 582 | + | |
| 583 | + | |
566 | 584 | | |
567 | 585 | | |
568 | | - | |
| 586 | + | |
569 | 587 | | |
570 | 588 | | |
571 | 589 | | |
| |||
622 | 640 | | |
623 | 641 | | |
624 | 642 | | |
625 | | - | |
| 643 | + | |
626 | 644 | | |
627 | | - | |
| 645 | + | |
628 | 646 | | |
629 | 647 | | |
630 | 648 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
378 | | - | |
| 378 | + | |
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
392 | | - | |
393 | | - | |
| 391 | + | |
394 | 392 | | |
395 | 393 | | |
396 | 394 | | |
| |||
406 | 404 | | |
407 | 405 | | |
408 | 406 | | |
409 | | - | |
| 407 | + | |
410 | 408 | | |
411 | 409 | | |
412 | 410 | | |
| |||
0 commit comments