Skip to content

Commit

Permalink
avm2: Always create four Stage3D instances
Browse files Browse the repository at this point in the history
This matches on the behavior on desktop, and at least one
SWF relies on having at least two Stage3D instances available.
  • Loading branch information
Aaron1011 authored and torokati44 committed Dec 28, 2024
1 parent 333cebe commit 0b296b5
Show file tree
Hide file tree
Showing 8 changed files with 965 additions and 9 deletions.
21 changes: 12 additions & 9 deletions core/src/display_object/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,19 +783,22 @@ impl<'gc> TDisplayObject<'gc> for Stage<'gc> {
stage_constr,
);

// Just create a single Stage3D for now
let stage3d = activation
.avm2()
.classes()
.stage3d
.construct(&mut activation, &[])
.expect("Failed to construct Stage3D");

match avm2_stage {
Ok(avm2_stage) => {
// Always create 4 Stage3D instances for now, which matches the flash projector behavior
let stage3ds: Vec<_> = (0..4)
.map(|_| {
activation
.avm2()
.classes()
.stage3d
.construct(&mut activation, &[])
.expect("Failed to construct Stage3D")
})
.collect();
let mut write = self.0.write(activation.gc());
write.avm2_object = Some(avm2_stage.into());
write.stage3ds = vec![stage3d];
write.stage3ds = stage3ds;
}
Err(e) => tracing::error!("Unable to construct AVM2 Stage: {}", e),
}
Expand Down
Loading

0 comments on commit 0b296b5

Please sign in to comment.