File tree 2 files changed +19
-4
lines changed 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use crate::avm2::string::AvmString;
4
4
use crate :: avm2:: value:: Value ;
5
5
use crate :: avm2:: Error ;
6
6
use crate :: avm2:: TObject ;
7
+ use crate :: PlayerMode ;
7
8
8
9
pub fn call_handler < ' gc > (
9
10
activation : & mut Activation < ' _ , ' gc > ,
@@ -24,6 +25,22 @@ pub fn get_stack_trace<'gc>(
24
25
) -> Result < Value < ' gc > , Error < ' gc > > {
25
26
let this = this. as_object ( ) . unwrap ( ) ;
26
27
28
+ // See <https://docs.ruffle.rs/en_US/FlashPlatform/reference/actionscript/3/Error.html#getStackTrace()>
29
+ // But note that the behavior also depends on SWF version.
30
+ let stack_trace_enabled = if activation. context . player_version >= 18
31
+ && activation. caller_movie_or_root ( ) . version ( ) >= 18
32
+ {
33
+ // For Flash Player 11.5+ and SWF>=18, stack traces are always enabled.
34
+ true
35
+ } else {
36
+ // For Flash Player Player 11.4 and earlier, or for SWF<18, stack traces are enabled for debug only.
37
+ activation. context . player_mode == PlayerMode :: Debug
38
+ } ;
39
+
40
+ if !stack_trace_enabled {
41
+ return Ok ( Value :: Null ) ;
42
+ }
43
+
27
44
if let Some ( error) = this. as_error_object ( ) {
28
45
let call_stack = error. call_stack ( ) ;
29
46
if !call_stack. is_empty ( ) {
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ use crate::string::WString;
10
10
use core:: fmt;
11
11
use gc_arena:: { Collect , Gc , GcWeak } ;
12
12
use std:: fmt:: Debug ;
13
- use tracing:: { enabled, Level } ;
14
13
15
14
/// A class instance allocator that allocates Error objects.
16
15
pub fn error_allocator < ' gc > (
@@ -19,9 +18,8 @@ pub fn error_allocator<'gc>(
19
18
) -> Result < Object < ' gc > , Error < ' gc > > {
20
19
let base = ScriptObjectData :: new ( class) ;
21
20
22
- let call_stack = ( enabled ! ( Level :: INFO ) || cfg ! ( feature = "avm_debug" ) )
23
- . then ( || activation. avm2 ( ) . call_stack ( ) . borrow ( ) . clone ( ) )
24
- . unwrap_or_default ( ) ;
21
+ // Stack trace is always collected for debugging purposes.
22
+ let call_stack = activation. avm2 ( ) . call_stack ( ) . borrow ( ) . clone ( ) ;
25
23
26
24
Ok ( ErrorObject ( Gc :: new (
27
25
activation. gc ( ) ,
You can’t perform that action at this time.
0 commit comments