Skip to content

Commit

Permalink
avm1: Do not unwrap parent when removing objects pending removal
Browse files Browse the repository at this point in the history
Turns out that sometimes objects pending removal do not have a parent.

I wasn't able to reproduce it, but it happens as we can see in error
reports.

Semantically this should be fine, as we mainly operate on the parent
here, but it's hard to be sure considering it's not reproducible.
It's better than panicking for sure.
  • Loading branch information
kjarosh authored and torokati44 committed Feb 12, 2025
1 parent 14a13f6 commit 9b18715
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions core/src/avm1/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,18 +444,20 @@ impl<'gc> Avm1<'gc> {
Self::find_display_objects_pending_removal(root_clip, &mut out);
}

for child in out {
for &child in &out {
// Get the parent of this object
let parent = child.parent().unwrap();
let parent_container = parent.as_container().unwrap();

// Remove it
parent_container.remove_child_directly(context, child);

// Update pending removal state
parent_container
.raw_container_mut(context.gc())
.update_pending_removals();
if let Some(parent_container) = child.parent().and_then(|p| p.as_container()) {
// Remove it
parent_container.remove_child_directly(context, child);

// Update pending removal state
parent_container
.raw_container_mut(context.gc())
.update_pending_removals();
} else {
// TODO Investigate it. This situation seems impossible, yet it happens.
tracing::warn!("AVM1 object pending removal doesn't have a parent, object={:?}, pending removal={:?}", child, out);
}
}
}

Expand Down

0 comments on commit 9b18715

Please sign in to comment.