bugGnash - The GNU Flash player - Bugs: bug #18523, ActionCallFunction do not see...

 
 

bug #18523: ActionCallFunction do not see local variables on the main timeline

Submitter:  Zou Lunkai <zoulunkai>
Submitted:  Thu 14 Dec 2006 08:41:19 AM UTC
   
 
Category:  ActionScript Severity:  3 - Normal
Release:  None Status:  Fixed
Privacy:  Public Assigned to:  strk
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 19 Dec 2006 05:52:50 AM UTC, comment #17: 

an updated "timeline_var_test_.c", attached as
"timeline_var_test_update_again.c"

(file #11556)

Zou Lunkai <zoulunkai>
Tue 19 Dec 2006 03:38:09 AM UTC, comment #16: 


>>So, if you confirm, the last bit left for this bug item is the
>>"FunctionActivator" thing, right ?

Mmm, I think there are still some bugs related to the "main timeline variable". I will update the "timeline_var_test_.c", to add something more...

Zou Lunkai <zoulunkai>
Mon 18 Dec 2006 03:54:36 PM UTC, comment #15: 

I've committed the new file in cvs, replacing the other one.
Note that I modified it to: 1) allow it to reach the last
frame and 2) use Dejagnu functionalities, for visual reports.

Also, it now runs fine.

So, if you confirm, the last bit left for this bug item is the
"FunctionActivator" thing, right ?

Sandro Santilli <strk>
Group Member
Sun 17 Dec 2006 06:36:33 AM UTC, comment #14: 

I have updated my test files, to make it "self-contained".
timeline_var_test_update.c and timeline_var_test_update.swf
Is it OK?

>>makeswf -o output.swf frame0.as frame1.as frame2.as

"output.swf" need to use three files or even more. It might not be easy to notice the  relationship between the "frame*.as" and "output.swf". Thanks for your tips.

(file #11545, file #11546)

Zou Lunkai <zoulunkai>
Fri 15 Dec 2006 04:50:37 PM UTC, comment #13: 

I've added your testcase generator code to CVS, before moving
to make a test runner an idea would be turning the SWF itself
to a self-contained one... do you wont to try that yourself ?
Being a Ming-based test this would be pretty easy, and we do
want to verify that the documentation related to this task is
complete enough so your attempt would help with that too...

Sandro Santilli <strk>
Group Member
Fri 15 Dec 2006 11:19:37 AM UTC, comment #12: 

I've a fix for your testcase: comment out the get_local_frame(),set_local_frame() and add_frame_barrier() in
sprite_instance::execute_action.

Unfortunately this change trigger failures in another
testcase which isn't with sources to add checks :/

movies.all/gravity_embedded-TestRunner

that's the only automatic test we have that loads an external
SWF, and the only one failing... will keep inspecting there.

Sandro Santilli <strk>
Group Member
Fri 15 Dec 2006 10:39:45 AM UTC, comment #11: 

About "sprite-frame" context, I agree with you, there should not be such context. The context is called "Timeline-scope", all frames should refer to that one. With Gnash this "context" is an as_environment, which is associated with each "sprite_instance".

as_environment then contains "local variables" organized in stacked
scopes, what you see listed as "Local variables" with -va (after my latest commits).

I guess these "scope stacks" are for function calls, and I added a section testing that in Function.as (seen it ?).

Anyway, your new test shows that local variables are reset when executing actions in a new "sprite" frame, so that's a good testcase.

btw, since we're on the same timezone.. what about stepping to #gnash on irc.freenode.net ?

Sandro Santilli <strk>
Group Member
Fri 15 Dec 2006 10:28:30 AM UTC, comment #10: 

Sorry, forget about using 'makeswf', the .c file is completely fine, let's not waste time :) was just intended to be a tip.

So, I would create a test "runner" for the SWF, using the MovieTester class. Do you want to do that part yourself to
easy further production of testcases, and also to validate
correctness and effectiveness of the Gnash manual informations
about it ?

Sandro Santilli <strk>
Group Member
Fri 15 Dec 2006 10:21:52 AM UTC, comment #9: 

The "frame" comments in as_environment refer to "scope frames"
not to "sprite frames". Consider the above:

var a=1; // a in frame0
{
  var a=2; // a in frame1
  {
     var a=3; // a in frame2
  }
}

It seems your test still doesn't work though, I suggest
you simplify the code by using 'makeswf':

makeswf -o output.swf frame0.as frame1.as frame2.as

If you want to make use of the Dejagnu.swf module you can
import it and wrap your frames in intialization/cleanup of
it like this:

(assuming you are in testsuite/misc_ming.all)

makeswf -i../Dejagnu.swf:dejagnu ../actionscript.all/dejagnu_so_init.as frame0.as frame1.as ../actionscript.all/dejagnu_so_fini.as

Note that dejagnu_so_fini.as just calls totals() and stop()
so you would not need your last frame.

Sandro Santilli <strk>
Group Member
Fri 15 Dec 2006 09:32:48 AM UTC, comment #8: 

AS I see, there's no variables belong to a specific frame. Frame should not be a context to any variable/function/ScriptObject. What do you think?

Zou Lunkai <zoulunkai>
Fri 15 Dec 2006 09:23:04 AM UTC, comment #7: 

Test Results(sources before 2006-12-14) with timeline_var_test.swf.

The AS in test file are like this

in frame 1
trace(var_at_frame2);

in frame 2
var_at_frame2 = "var_defined_at_frame2"

in frame 3
gotoAndStop(1);

The results should be:
undefined
var_defined_at_frame2

Gnash output:
undefined
undefined

Zou Lunkai <zoulunkai>
Fri 15 Dec 2006 09:13:32 AM UTC, comment #6: 


>>Found out that if instead of 'var timeline=' we >>use 'timeline=' Gnash works.

Can not quite understand 'var timeline='.


>>var timelinevar = "tlv";
>>a_func = function()
>>{
>>  check_equals(timelinevar, "tlv");
>>};
>>a_func();
>>It fails, ...
>>The difference is that 'var timeline=' uses ActionVarEquals
>>(Set local: 0x3c) while 'timeline=' uses ActionSetVariable
>>(0x1D).

Both of the AS(0x3C, 0x1D) could define a new variable. Gnash stores the newly created variables at different places, but can not find it later. Your testcase is easy to debug, but the result really surprise me.  I then wrote another testcase. There is no function, but the variable still could not be found(before your update).

See my attached file:
timeline_var_test.swf  and timeline_var_test.c

Since you have update the source, Gnash could probably produce the right result now(I haven't done the test). I just want to use it to clarify your questions in file "as_environment.cpp".
"
    // Is it in the current frame already?
    // TODO: should we descend to upper frames ?
    //       (probably not as we want to update it)
"
My answer is yes, and we should scan all the frames.




(file #11529, file #11530)

Zou Lunkai <zoulunkai>
Thu 14 Dec 2006 11:48:41 PM UTC, comment #5: 

I've enabled 'local variables' debugging and what I see
makes me think gnash is actually doing the right thing, while the MM player is bogus..

Here is the code:

 var result2 = "initial_result2_value";
 outer_func = function() {
        var a = "hello"; // this is a function-local !!

        inner_func = function(var_ref) {
                return(eval(var_ref));
        };
 };
 outer_func(); // creates inner_func variable on timeline
 result2 = inner_func("a");  // [1]

[1] Why in the world should "a" be found there ??
    "a" is a local function of outer_func and it should
    go away as soon as outer_func() returns
    (and this is what happens with Gnash).
    Is it possible that the fact the MM player works is
    just higly implementation-defined ? (maybe they
    happen to store locals for more time then required..)

Sandro Santilli <strk>
Group Member
Thu 14 Dec 2006 02:09:23 PM UTC, comment #4: 

I committed a reviewed testcase and a fix for timeline-local
access. The inner_func call failure is still unresolved, so
I marked it as an 'expected' failure for now.
Anyway, please review the code so that in case some other
check comes to your mind you can provide a patch.
You will see I added a completely new section before
your own that checks more specific things, those checks
show that 'inner_func' IS defined on the timeline after
call to outer_func (that defines it), so the problem seems
related to handling of the return or something like
that.

The code is in Function.as

Sandro Santilli <strk>
Group Member
Thu 14 Dec 2006 12:36:43 PM UTC, comment #3: 

Ok, the "locals" access is fixed, now the last bit
of test still not working is callign 'inner_func' from
the timeline. I'll commit when this works too.

Oh, there's also another failure, the one for SWF5.
Will ask you to review the new testing code when
it is committed.

Sandro Santilli <strk>
Group Member
Thu 14 Dec 2006 11:33:43 AM UTC, comment #2: 

Found out that if instead of 'var timeline=' we use 'timeline='
Gnash works.

The difference is that 'var timeline=' uses ActionVarEquals
(Set local: 0x3c) while 'timeline=' uses ActionSetVariable (0x1D).

..

Sandro Santilli <strk>
Group Member
Thu 14 Dec 2006 10:47:04 AM UTC, comment #1: 

Thanks a lot for this, we need these kind of testcases :)

I've reduced your testcase to this:

 var timelinevar = "tlv";
 a_func = function()
 {
        check_equals(timelinevar, "tlv");
 };
 a_func();

It fails, and this seems to be the culprit.
I'll work on this, and when it's fixed will try
the larger test, that I plan to include in the
existing Function.as function.



Sandro Santilli <strk>
Group Member
Thu 14 Dec 2006 08:41:19 AM UTC, original submission:  


Tested with Gnash_HEAD.

It seems that nested function could not be processed correctly. My testing codes are as follows:

/start of test
var  result1 = null;
var  result2 = null;

outer_func = function()
{
  var a = "hello";

  inner_func = function(var_ref)
  {
    return(eval(var_ref));
  };
 
  result1 = inner_func("a");  // return "hello"
};

call outer_func to set result1
outer_func();

result2 = inner_func("a");    // return "hello"
/// end of test


With SWF version >= 6, the result is expected to be:
hello
hello
Gnash output:
undefined
undefined

Use "-va" do not report apparent information of mistakes.

Attached file description:
nested_function_test.swf:  the test swf file which produces unexpected results;
nested_function_test.as:  the "Ming" based source file;



Zou Lunkai <zoulunkai>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #11545:  timeline_var_test_update.swf added by zoulunkai (494B - application/x-shockwave-flash)
file #11529:  timeline_var_test.swf added by zoulunkai (151B - application/x-shockwave-flash)
file #11530:  timeline_var_test.c added by zoulunkai (2KiB - text/plain)
file #11522:  nested_function_test.swf added by zoulunkai (392B - application/x-shockwave-flash)
file #11523:  nested_function_test.as added by zoulunkai (2KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by strk (Posted a comment)
  • -email is unavailable- added by zoulunkai (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 15 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-01-30 strk StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2006-12-19 zoulunkai Attached File- Added timeline_var_test_update_again.c, #11556
    2006-12-18 strk StatusIn Progress Ready For Test
    2006-12-17 zoulunkai Attached File- Added timeline_var_test_update.swf, #11545
        Attached File- Added timeline_var_test_update.c, #11546
    2006-12-15 strk Carbon-Copy- Added ann
    2006-12-15 zoulunkai Attached File- Added timeline_var_test.swf, #11529
        Attached File- Added timeline_var_test.c, #11530
    2006-12-14 strk SummaryActionCallFunction do not see variables on the main timeline ActionCallFunction do not see local variables on the main timeline
    2006-12-14 strk StatusNone In Progress
        Assigned toNone strk
        SummaryActionCallFunction do no return right result as expected ActionCallFunction do not see variables on the main timeline
    2006-12-14 zoulunkai Attached File- Added nested_function_test.swf, #11522
        Attached File- Added nested_function_test.as, #11523

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code