This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Allow hot reload without syncing all asset files to devFS #21436
Merged
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d870dea
Allow hot reload without syncing all asset files to devFS
jonahwilliams 847b53d
Update asset_manager.cc
62cea76
only preserve original asset manager
jonahwilliams ec3ba29
Update asset_manager.cc
9ebdec9
Update engine.cc
262912a
always re-create original asset dir
jonahwilliams 0ebce10
Merge branch 'double_devfs' of github.com:jonahwilliams/engine into d…
jonahwilliams 5a95412
remove missed merge
jonahwilliams cb3e7b1
fix order of asset resolvers
jonahwilliams 32f85bd
add shell unit test for setting asset dir path
jonahwilliams f42dd5e
maybe this works
jonahwilliams f004337
make a private member
jonahwilliams ee6772a
format
jonahwilliams File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,8 @@ class AssetManager final : public AssetResolver { | |
|
|
||
| void PushBack(std::unique_ptr<AssetResolver> resolver); | ||
|
|
||
| void Merge(std::shared_ptr<AssetManager> assetManager); | ||
|
||
|
|
||
| // |AssetResolver| | ||
| bool IsValid() const override; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,12 +111,13 @@ bool Engine::UpdateAssetManager( | |
| if (asset_manager_ == new_asset_manager) { | ||
| return false; | ||
| } | ||
|
|
||
| auto old_asset_manager = asset_manager_; | ||
| asset_manager_ = new_asset_manager; | ||
|
|
||
| if (!asset_manager_) { | ||
| return false; | ||
| } | ||
| asset_manager_->Merge(old_asset_manager); | ||
|
||
|
|
||
| // Using libTXT as the text engine. | ||
| font_collection_.RegisterFonts(asset_manager_); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About the name,
Mergetypically means that all the elements will be combined somehow, but it doesn't look like that's what this is doing.I'd like to suggest a better name, but I think I don't understand what is special about the last resolver of
assetManager.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
PreserveBundleManageror something like that?The very last resolve is the first one ever added, which is the one that resolves assets from the APK/IPA bundle that is installed with the device. Preserving it means that we don't need to sync every asset into the devFS when connecting to a device
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would something like this work?
AssetManageradds an API to declare which asset resolvers should be preserved across a hot reloadShell::OnServiceProtocolSetAssetBundlePathretains those resolvers when constructing the newAssetManagerThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would have to be done in engine.cc since the current asset manager will be private. I could add a param to the directory asset resolver that controls whether it should be preserved and then set this to true for the initial resolvers.