Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(assets): Sort asset dependency cids before updating parent cid #286

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions framework_crates/bones_asset/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,14 @@ impl AssetServer {
};

// Update Cid with the Cids of it's dependencies
dependencies.sort();

// TODO: Dependencies should be sorted as a consistent order is required to
// compute the same cid. We can't sort Vec<UntypedHandle>, runtime IDs vary each run.
//
// dependencies.sort();

// For now, gather cids and sort them before update
let mut dep_cids: Vec<Cid> = vec![];
for dep in &dependencies {
let dep_cid = loop {
let listener = self.load_progress.listen();
Expand All @@ -645,6 +652,12 @@ impl AssetServer {
};
break *cid;
};
// cid.update(dep_cid.0.as_slice());
dep_cids.push(dep_cid);
}

dep_cids.sort();
for dep_cid in dep_cids {
cid.update(dep_cid.0.as_slice());
}

Expand Down Expand Up @@ -710,8 +723,16 @@ impl AssetServer {
let sbox = loader.load(ctx, contents).await?;

// Update Cid with the Cids of it's dependencies
let mut dependencies = dependencies.iter().cloned().collect::<Vec<_>>();
dependencies.sort();
let dependencies = dependencies.iter().cloned().collect::<Vec<_>>();

// TODO: Dependencies should be sorted as a consistent order is required to
// compute the same cid. We can't sort Vec<UntypedHandle>, runtime IDs vary each run.
//
// dependencies.sort();

// For now, gather cids and sort them before update
let mut dep_cids: Vec<Cid> = vec![];

for dep in &dependencies {
let dep_cid = loop {
let listener = self.load_progress.listen();
Expand All @@ -721,6 +742,11 @@ impl AssetServer {
};
break *cid;
};
dep_cids.push(dep_cid);
// cid.update(dep_cid.0.as_slice());
}
dep_cids.sort();
for dep_cid in dep_cids {
cid.update(dep_cid.0.as_slice());
}

Expand Down
Loading