Skip to content
Open
Show file tree
Hide file tree
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
34 changes: 34 additions & 0 deletions core/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,30 @@
self.0.get_mut(handle)
}

/// Checks if the target clip on the given handle's loader
/// has been `avm1_removed()`. If so, it will set the `loader_status`
/// to `Failed` and return `true`.
/// This is used to prevent a loaded movie from executing
/// if its target clip was removed before it finished loading.
// TODO: Does this need adjusted for clip unloading?
// (see the avm1/load_cancel_via_unloadclip and avm1/load_cancel_via_unloadmovie tests)
pub fn load_cancelled_avm1(&mut self, handle: LoaderHandle) -> bool {
match self.get_loader_mut(handle) {
Some(MovieLoader {
loader_status,
target_clip,
..
}) => {
if target_clip.avm1_removed() {
*loader_status = LoaderStatus::Failed;
return true;
}
}
_ => unreachable!(),

Check warning on line 276 in core/src/loader.rs

View workflow job for this annotation

GitHub Actions / Coverage Report

Coverage

Uncovered line (276)
}
false
}

/// Kick off a movie clip load.
///
/// Returns the loader's async process, which you will need to spawn.
Expand Down Expand Up @@ -658,6 +682,11 @@
None => return Err(Error::Cancelled),
};

if uc.load_manager.load_cancelled_avm1(handle) {
tracing::warn!("movie_loader: Target clip was already AVM1 removed");
return Err(Error::Cancelled);
}

replacing_root_movie = uc
.stage
.root_clip()
Expand Down Expand Up @@ -1590,6 +1619,11 @@
None => return Err(Error::Cancelled),
};

if uc.load_manager.load_cancelled_avm1(handle) {
tracing::warn!("movie_loader_data: Target clip was already avm1_removed");
return Ok(());

Check warning on line 1624 in core/src/loader.rs

View workflow job for this annotation

GitHub Actions / Coverage Report

Coverage

Uncovered lines (1623–1624)
}

let domain = if let MovieLoaderVMData::Avm2 {
context,
default_domain,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mc_loadMovie: _level0.mc_loadMovie
mc_loadMovie:
mc_mcl: _level0.mc_mcl
mc_mcl:
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 4
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mc_mcl: _level0.mc_mcl
mc_mcl: _level0.mc_mcl
MovieClipLoader.onLoadStart
_level0.mc_mcl - this should not trace!
MovieClipLoader.onLoadInit
3 changes: 3 additions & 0 deletions tests/tests/swfs/avm1/load_cancel_via_unloadclip/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mc_mcl: _level0.mc_mcl
mc_mcl: _level0.mc_mcl
MovieClipLoader.onLoadStart
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/tests/swfs/avm1/load_cancel_via_unloadclip/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
num_ticks = 4
known_failure = true
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mc_loadMovie: _level0.mc_loadMovie
mc_loadMovie: _level0.mc_loadMovie
mc_mcl: _level0.mc_mcl
mc_mcl: _level0.mc_mcl
MovieClipLoader.onLoadStart
_level0.mc_mcl - this should not trace!
_level0.mc_loadMovie - this should not trace!
MovieClipLoader.onLoadInit
5 changes: 5 additions & 0 deletions tests/tests/swfs/avm1/load_cancel_via_unloadmovie/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mc_loadMovie: _level0.mc_loadMovie
mc_loadMovie: _level0.mc_loadMovie
mc_mcl: _level0.mc_mcl
mc_mcl: _level0.mc_mcl
MovieClipLoader.onLoadStart
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/tests/swfs/avm1/load_cancel_via_unloadmovie/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
num_ticks = 4
known_failure = true
Loading