bugGnash - The GNU Flash player - Bugs: bug #37223, JavaScript call didn't reach the...

 
 

bug #37223: JavaScript call didn't reach the ExternalInterface callback

Submitter:  Nutchanon Wetchasit <nachanon>
Submitted:  Thu 30 Aug 2012 09:09:26 AM UTC
Votes: 25
 
Category:  plugin Severity:  3 - Normal
Release:  0.8.10 Status:  Ready For Test
Privacy:  Public Assigned to:  strk
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 07 Mar 2016 12:31:50 PM UTC, comment #26: 
Nutchanon Wetchasit <nachanon>
Mon 07 Mar 2016 06:21:28 AM UTC, comment #25: 

Patch included for fixing `instance=null` and `instance=undefined` case.
See patch #8933.

This is text output from `js2flash-nothis-v2.html` on browser with patched Gnash:

PASSED: Flash should properly register nullthis_call ExternalInterface callback
PASSED: Flash should properly register undefinedthis_call ExternalInterface callback
PASSED: Flash should properly register globalcheck_call ExternalInterface callback
PASSED: ExternalInterface should be available
PASSED: nullthis_call ExternalInterface callback registration should not fail
PASSED: undefinedthis_call ExternalInterface callback registration should not fail
PASSED: globalcheck_call ExternalInterface callback registration should not fail
PASSED: nullthis_call ExternalInterface callback should be called
PASSED: this pointer inside nullthis_call should be equal to undefined value
PASSED: this pointer inside nullthis_call should be equal to null value
PASSED: this pointer inside nullthis_call should not strictly equal to undefined value
PASSED: this pointer inside nullthis_call should not strictly equal to null value
PASSED: Appending this pointer inside nullthis_call to empty string should give "undefined" string
PASSED: this pointer inside nullthis_call should be strictly equal to _global object
PASSED: undefinedthis_call ExternalInterface callback should be called
PASSED: this pointer inside undefinedthis_call should be equal to undefined value
PASSED: this pointer inside undefinedthis_call should be equal to null value
PASSED: this pointer inside undefinedthis_call should not strictly equal to undefined value
PASSED: this pointer inside undefinedthis_call should not strictly equal to null value
PASSED: Appending this pointer inside undefinedthis_call to empty string should give "undefined" string
PASSED: this pointer inside undefinedthis_call should be strictly equal to _global object
PASSED: globalcheck_call ExternalInterface callback should be called
PASSED: _global.nullthis_value should be set to the correct value
PASSED: _global.undefinedthis_value should be set to the correct value
PASSED: There should be 25 tests run


You'd see that all tests are now showing PASSED result.

Note: The `Function.call()` issue mentioned in the patch entry will be
reported separately after additional testing are done.

Gnash: 0.8.11dev (patched against git 9229f6f 3-Mar-2016) NPAPI
Browser: Iceweasel 10.0.12 (debian)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Mon 07 Mar 2016 06:00:49 AM UTC, comment #24: 

I have made a revised version of `js2flash-nothis.zip` test, which include
additional checks on relationship between `this` object inside callback
without context and the `_global` object, by trying to set some property
to `this` inside the callback, and check for them in `_global` outside
the callback.

The test is attached as `js2flash-nothis-v2.zip`.

Gnash: 0.8.11dev (git 9229f6f 3-Mar-2016) NPAPI
Flash Player: 11.2 r202 (11.2.202.491) NPAPI binary
Browser: Iceweasel 10.0.12 (debian)
System: Debian GNU/Linux 7.0 Wheezy i386


(file #36563)

Nutchanon Wetchasit <nachanon>
Sat 05 Mar 2016 05:16:31 PM UTC, comment #23: 

From more testing and a hint from Gnash's `Function.call()` implementation,
I found that the correct `this` object inside ExternalInterface
callback registered with `undefined` or `null` instance is, in fact,
ActionScript's `_global` object.

I have made a semi-automated test SWF/HTML for verifying this aspect of
ExternalInterface, attached as `js2flash-nothis.zip`.

This is text output from `js2flash-nothis.html` on browser with Flash Player:

PASSED: Flash should properly register nullthis_call ExternalInterface callback
PASSED: Flash should properly register undefinedthis_call ExternalInterface callback
PASSED: ExternalInterface should be available
PASSED: nullthis_call ExternalInterface callback registration should not fail
PASSED: undefinedthis_call ExternalInterface callback registration should not fail
PASSED: nullthis_call ExternalInterface callback should be called
PASSED: this pointer inside nullthis_call should be equal to undefined value
PASSED: this pointer inside nullthis_call should be equal to null value
PASSED: this pointer inside nullthis_call should not strictly equal to undefined value
PASSED: this pointer inside nullthis_call should not strictly equal to null value
PASSED: Appending this pointer inside nullthis_call to empty string should give "undefined" string
PASSED: this pointer inside nullthis_call should be strictly equal to _global object
PASSED: undefinedthis_call ExternalInterface callback should be called
PASSED: this pointer inside undefinedthis_call should be equal to undefined value
PASSED: this pointer inside undefinedthis_call should be equal to null value
PASSED: this pointer inside undefinedthis_call should not strictly equal to undefined value
PASSED: this pointer inside undefinedthis_call should not strictly equal to null value
PASSED: Appending this pointer inside undefinedthis_call to empty string should give "undefined" string
PASSED: this pointer inside undefinedthis_call should be strictly equal to _global object
PASSED: There should be 19 tests run


You'd see that all checks were passed.

This is text output from `js2flash-nothis.html` on browser with Gnash:

PASSED: Flash should properly register nullthis_call ExternalInterface callback
PASSED: Flash should properly register undefinedthis_call ExternalInterface callback
PASSED: ExternalInterface should be available
PASSED: nullthis_call ExternalInterface callback registration should not fail
PASSED: undefinedthis_call ExternalInterface callback registration should not fail
PASSED: nullthis_call ExternalInterface callback should be called
PASSED: this pointer inside nullthis_call should be equal to undefined value
PASSED: this pointer inside nullthis_call should be equal to null value
PASSED: this pointer inside nullthis_call should not strictly equal to undefined value
FAILED: this pointer inside nullthis_call should not strictly equal to null value
FAILED: Appending this pointer inside nullthis_call to empty string should give "undefined" string ("null" != "undefined")
FAILED: this pointer inside nullthis_call should be strictly equal to _global object
PASSED: undefinedthis_call ExternalInterface callback should be called
PASSED: this pointer inside undefinedthis_call should be equal to undefined value
PASSED: this pointer inside undefinedthis_call should be equal to null value
PASSED: this pointer inside undefinedthis_call should not strictly equal to undefined value
FAILED: this pointer inside undefinedthis_call should not strictly equal to null value
FAILED: Appending this pointer inside undefinedthis_call to empty string should give "undefined" string ("null" != "undefined")
FAILED: this pointer inside undefinedthis_call should be strictly equal to _global object
PASSED: There should be 19 tests run


You'd see that checks were failed in the same way as current XFAILs in
extcomm test of Gnash testsuite.

Gnash: 0.8.11dev (git 9229f6f 3-Mar-2016) NPAPI
Flash Player: 11.2 r202 (11.2.202.491) NPAPI binary
Browser: Iceweasel 10.0.12 (debian)
System: Debian GNU/Linux 7.0 Wheezy i386


(file #36557)

Nutchanon Wetchasit <nachanon>
Sat 26 Dec 2015 02:48:19 PM UTC, comment #22: 

Ideally there would be a single test composed by one (or more) SWF files and one (or more) HTML files so that anyone could point a web browser to the test entry point and intuitively see what's failing what's succeeding and what's running (test summary); then a test runner would somehow simulate the html interaction in an automated way (webkit-based, for example).

Failing to do that, an easier solution could be for the test runner to generate an HTML file that would replicate what the test runner does and contain instructions for the tester as for what's expected and what's obtained.

Note that all the tests under testsuite/actionscript.all are similar in this regard (self-contained tests) but were simpler to implement because do not require bidirectional host communication.

Sandro Santilli <strk>
Group Member
Sat 26 Dec 2015 12:53:14 PM UTC, comment #21: 

The rest of automated tests mentioned in comment comment 7 are now included.
See patch #8840.

For `instance=null` and `instance=undefined` issue, I'm going to revisit
these cases and look for a way to emulate `function.call()` in this aspect,
so it would give a correct output.

Anyway, should a semi-automated HTML-based test runner (like
`js2flash-testrunner.html` in file #35071) be included too?
(In case of testing against proprietary Flash Player)

Gnash: 0.8.11dev (patched against git 4c03566 19-Dec-2015)
Adobe Flash Player: 11.2 r202 (11.2.202.491) NPAPI binary
Browser: Iceweasel 10.0.12 (debian)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Tue 13 Oct 2015 09:46:45 AM UTC, comment #20: 

An integrated version of `js2flash-auto` test is now included,
see patch #8770.

Gnash: 0.8.11dev (patched against git f0f66ce 23-Sep-2015)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Tue 06 Oct 2015 04:26:34 PM UTC, comment #19: 

It could be integrated under testsuite/misc-mtasc.all, can you try that ? Maybe renaming the dir to js2flash

Sandro Santilli <strk>
Group Member
Mon 05 Oct 2015 09:16:06 AM UTC, comment #18: 

For a version of `js2flash-auto.tar.gz` that include an optional
HTML container/manual test runner, see the attached `js2flash-auto-v2.tar.gz`.

Gnash: Gnash 0.8.11dev (patched against git f0f66ce 23-Sep-2015) NPAPI
Browser: Iceweasel 10.0.12 (debian)
System: Debian GNU/Linux 7.0 Wheezy i386


(file #35071)

Nutchanon Wetchasit <nachanon>
Mon 05 Oct 2015 07:06:02 AM UTC, comment #17: 

I have made an example automated (but non-integrated) version of
`js2flash-rootcb.html` test, using host container emulation approach with
bourne shell script and named pipes. See the attached `js2flash-auto.tar.gz`.

It currently gives a `PASSED` result despite being a line-based tester
which depends on bug #46115 (container message line delimiting issue)
being fixed; due to the fact that there's only one return value check
done at the last message from player, combined with tester's built-in
timeout provision.

PASSED: Gnash should properly register an ExternalInterface callback
PASSED: Gnash should return a correct value from ExternalInterface callback
PASSED: Gnash should terminate successfully
PASSED: ExternalInterface should be available
PASSED: ExternalInterface registration should not fail
PASSED: ExternalInterface-registered callback should be called
PASSED: ExternalInterface should pass correct callback arguments
PASSED: There should be 7 tests run


But this wouldn't hold if there are multiple return value tests done
in the script.

Gnash: Gnash 0.8.11dev (git f0f66ce 23-Sep-2015)
System: Debian GNU/Linux 7.0 Wheezy i386


(file #35064)

Nutchanon Wetchasit <nachanon>
Sat 03 Oct 2015 05:21:32 PM UTC, comment #16: 

For an issue on how Gnash delimit messages sent to host controller,
which affects how automated container-emulation tests could be written,
see bug #46115.

Nutchanon Wetchasit <nachanon>
Mon 28 Sep 2015 03:13:18 AM UTC, comment #15: 

For the libgnashplugin's crash in Object/Array return type mentioned
on comment 4, I suspect that it was caused by bug #32411 (plugin's nested XML parsing issue).

Nutchanon Wetchasit <nachanon>
Wed 19 Aug 2015 10:51:22 AM UTC, comment #14: 

if js2flash.swf is enough for testing all it takes, it may be a good idea to implement the test runner using MovieTester, see how it is done with testsuite/movies.all/tic_tac2-TestRunner.cpp as an example, or any of the testsuite/misc-ming.all/*Runner.cpp files.

It might take some enhancement to make working with filedescriptors easier.

Sandro Santilli <strk>
Group Member
Wed 19 Aug 2015 10:46:28 AM UTC, comment #13: 

@strk
I didn't see your previous post, sorry.

I'll try to work on automated test case from now on.
Thanks.

Nutchanon Wetchasit <nachanon>
Wed 19 Aug 2015 10:37:17 AM UTC, comment #12: 

After several experiments, I think GC provision provided in previous
patches might not enough to prevent Function/Object registered via
`ExternalInterface.addCallback()` from being garbage-collected in a long run.
(The code would only prevent it in first GC iteration, if at all)

See patch #8720 for possible fix.

After applying the fix, running Gnash like

gtk-gnash -vv --fd 3:4 js2flash.swf 3>&1 4<&0


will not result in crash, and js2flash.html now works on browser
without crashing too.

Gnash: 0.8.11dev (patched against git c5b657f 17-Aug-2015) NPAPI
Browser: Iceweasel 10.0.12 (debian)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Wed 19 Aug 2015 10:32:44 AM UTC, comment #11: 

Third patch in as 88f86a3 -- looking forward for automated tests

Sandro Santilli <strk>
Group Member
Wed 19 Aug 2015 09:24:48 AM UTC, comment #10: 

Running original js2flash test case (not js2flash-rootcb) on current Gnash git
(using either fake host container configuration, or running `js2flash.html`
via browser) would now cause it to crash:


$ gdb gtk-gnash
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/local/bin/gtk-gnash...done.
(gdb) run -v --fd 2:3 js2flash.swf 2>&1 3>&0
Starting program: /usr/local/bin/gtk-gnash -v --fd 2:3 js2flash.swf 2>&1 3>&0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
[New Thread 0xb3f99b70 (LWP 20052)]
[Thread 0xb3f99b70 (LWP 20052) exited]
20048:1] 355 SECURITY: Checking security of URL 'file:///home/window/Desktop/js2flash.swf'
20048:1] 356 SECURITY: Load of file /home/window/Desktop/js2flash.swf granted (under local sandbox /home/window/Desktop/)
20048:1] 367 SECURITY: Extensions disabled
[New Thread 0xb3f99b70 (LWP 20053)]
20048:2] 369 UNIMPLEMENTED: FileAttributes tag in the SWF requests that network access is not granted to this movie (or application?) when loaded from the filesystem. Anyway Gnash won't care; use white/black listing in your .gnashrc instead
[Thread 0xb3f99b70 (LWP 20053) exited]
20048:1] 456 TRACE: callee: load
20048:1] 456 TRACE: callee: finished loading
20048:1] 456 TRACE: callee: first run
20048:1] 456 TRACE: callee: external initializing
20048:1] 456 SECURITY: Checking security of URL 'file:///home/window/Desktop/WINDOW-NB'
20048:1] 456 SECURITY: Load of file /home/window/Desktop/WINDOW-NB granted (under local sandbox /home/window/Desktop/)
20048:1] 456 TRACE: callee: adding callback
<invoke name="addMethod" returntype="xml"><arguments><string>script_call</string></arguments></invoke>
20048:1] 456 TRACE: callee: finished first run
20048:1] 546 TRACE: status: load
20048:1] 546 TRACE: status: finished loading
20048:1] 547 TRACE: status: load
20048:1] 547 TRACE: status: finished loading

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) backtrace
#0  0x00000000 in ?? ()
#1  0xb7d14fa9 in gnash::DisplayList::add_invalidated_bounds (this=0x801feb14, ranges=..., force=true) at DisplayList.cpp:688
#2  0xb7cd6b91 in gnash::MovieClip::add_invalidated_bounds (this=0x801fea58, ranges=..., force=false) at MovieClip.cpp:1657
#3  0xb7d16549 in gnash::DisplayList::add_invalidated_bounds (this=0xb3407e74, ranges=..., force=false) at DisplayList.cpp:703
#4  0xb7cd6b91 in gnash::MovieClip::add_invalidated_bounds (this=0xb3407db8, ranges=..., force=false) at MovieClip.cpp:1657
#5  0xb7d16549 in gnash::DisplayList::add_invalidated_bounds (this=0xb3407b44, ranges=..., force=false) at DisplayList.cpp:703
#6  0xb7cd6b91 in gnash::MovieClip::add_invalidated_bounds (this=0xb3407a88, ranges=..., force=false) at MovieClip.cpp:1657
#7  0xb7cbd0db in gnash::movie_root::add_invalidated_bounds (this=0xbfffe1bc, ranges=..., force=false) at movie_root.cpp:1367
#8  0x8002dce3 in gnash::Gui::display (this=this@entry=0x800bfad0, m=m@entry=0xbfffe1bc) at gui.cpp:724
#9  0x80030bcc in gnash::Gui::advanceMovie (this=0x800bfad0, doDisplay=true) at gui.cpp:974
#10 0x8004dfd3 in gnash::Gui::advance_movie (gui=gui@entry=0x800bfad0) at ./gui.h:273
#11 0xb734e3af in g_timeout_dispatch (source=source@entry=0x801f6930, callback=0x8004dfb0 <gnash::Gui::advance_movie(gnash::Gui*)>, user_data=0x800bfad0)
    at /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./glib/gmain.c:3882
#12 0xb734d6d3 in g_main_dispatch (context=0x800f4960) at /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./glib/gmain.c:2539
#13 g_main_context_dispatch (context=context@entry=0x800f4960)
    at /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./glib/gmain.c:3075
#14 0xb734da70 in g_main_context_iterate (context=0x800f4960, block=block@entry=1, dispatch=dispatch@entry=1,
    self=<error reading variable: Unhandled dwarf expression opcode 0xfa>)
    at /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./glib/gmain.c:3146
#15 0xb734decb in g_main_loop_run (loop=loop@entry=0x801fb048)
    at /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./glib/gmain.c:3340
#16 0xb7664ad0 in IA__gtk_main () at /build/buildd-gtk+2.0_2.24.10-2-i386-Tg7Q_2/gtk+2.0-2.24.10/gtk/gtkmain.c:1256
#17 0x80046b28 in gnash::GtkGui::run (this=0x800bfad0) at gtk/gtk.cpp:258
#18 0x8003a8b3 in gnash::Player::run (this=0xbfffeb00, argc=-2145389948, argv=0xbffff414, infile=..., url=...) at Player.cpp:664
#19 0x80014fb0 in playFile (player=..., argc=5, argv=0xbffff414, filename=...) at gnash.cpp:92
#20 0x8001ac95 in __call<void, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, 0u, 1u, 2u, 3u> (__args=..., this=0xbfffef28)
    at /usr/include/c++/4.7/functional:1156
#21 operator()<std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, void> (this=0xbfffef28) at /usr/include/c++/4.7/functional:1215
#22 std::for_each<__gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >, std::_Bind<void (*(std::reference_wrapper<gnash::Player>, int, char**, std::_Placeholder<1>))(gnash::Player&, int, char**, std::string const&)> >(__gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >, __gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >, std::_Bind<void (*(std::reference_wrapper<gnash::Player>, int, char**, std::_Placeholder<1>))(gnash::Player&, int, char**, std::string const&)>) (__first=..., __last=..., __f=...)
    at /usr/include/c++/4.7/bits/stl_algo.h:4442
#23 0x80013747 in main (argc=5, argv=0xbffff414) at gnash.cpp:176
(gdb) quit
A debugging session is active.

        Inferior 1 [process 20048] will be killed.

Quit anyway? (y or n) y



I suspect that GC-related part of previous patches is the culprit.

Gnash: 0.8.11dev (git c5b657f 17-Aug-2015) NPAPI
Browser: Iceweasel 10.0.12 (debian)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Sun 16 Aug 2015 08:57:23 AM UTC, comment #9: 

second patch also committed as 25395ad8ac5fa389d7cf18bbdf61daa7caa0c578

Keeping this open in "Ready for test" mode for adding tests and running some manual tests too..

Sandro Santilli <strk>
Group Member
Sun 16 Aug 2015 07:45:48 AM UTC, comment #8: 

shell or perl script seems to be the way to go. We already have a perl script for testing XMLSocket. The list of tests seems good to me!

NOTE: your first patch was pushed as commit:554c4638cc3a11dda8f54ba638de7a0445d345ad

Sandro Santilli <strk>
Group Member
Sun 16 Aug 2015 05:02:37 AM UTC, comment #7: 

As for testing, the thing is, what is a proper way to test ExternalInterface?
ActionScript-only test cases (like ones I saw in `testsuite/misc-mtasc.all`)
won't cut it, since this involves browser-Gnash interaction.

An alternative would be writing some (shell or Perl) script that fakes
Gnash's host container (run gnash with`--fd` option), and verify result
from both side. I haven't looked closely on this method yet.
Any suggestion?

By the way, these are list of simple tests I planned to write:

  • Registered callback invocation test: ExternalInterface callback (pass) V.S. _root callback (fail), aka. an automated version of js2flash-rootcb test.
  • Registration test with `method=null` and `method=undefined`: callback registration must fail to pass.
  • Registration test with `instance=null`: callback registration should succeed to pass.
  • Test on `this` inside callback when `instance!=null`: user-specified Object (pass) V.S. registering code's `this` (fail) V.S. Function's class (fail) V.S. _root (fail).
  • Test on `this` inside callback when `instance=null`: must be an empty value (`null` or `undefined`) and instance variable reference must give `undefined` to pass.
  • Test on `this` inside callback when `instance=null`: must give `undefined` to pass. (This one is expected to fail)
  • Long callback arguments test ("The","quick","brown","fox","jumps","over","the","lazy","dog"): must be passed correctly to pass.


Nutchanon Wetchasit <nachanon>
Sun 16 Aug 2015 03:20:00 AM UTC, comment #6: 

Patch included (2 of 2), see patch #8715 comment 5.

The patch fixes following issue:

  • Actual value of `instance` argument was ignored; Gnash used `_root` instead.


Note:
In special case where user specified `instance=null` or `instance=undefined`,
under Flash Player, it make `this` reference return `undefined` inside
the callback. Under Gnash, there is a limitation which caused `this`
reference to return `null` inside the callback in these cases instead.

Gnash: 0.8.11dev (patched against git 6b269f9 24-May-2015) NPAPI
Browser: Iceweasel 10.0.12 (debian)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Thu 13 Aug 2015 04:30:55 PM UTC, comment #5: 

Patch included (1 of 2), see patch #8715.

The patch fixes following issues:

  • `method` argument was ignored; Gnash called `_root.methodName` instead.
  • Registration failed silently if `instance` argument is `null` or `undefined`.
  • Gnash only passed maximum 3 arguments to the callback; specifiying more than 3 would have same result as passing 0 argument.


Note: js2flash-rootcb.html should give a correct result after applying this patch.

Gnash: 0.8.11dev (patched against git 6b269f9 24-May-2015) NPAPI
Browser: Iceweasel 10.0.12 (debian)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Mon 10 Aug 2015 10:11:05 AM UTC, comment #4: 

These are list of problems found in Gnash's ExternalInterface implementation
(JavaScript -> Flash direction) as far as I have tested.

Problems with callback registration, `ExternalInterface.addCallback(methodName,instance,method)`:

  • `method` argument is ignored; Gnash calls `_root.methodName` instead. (The original submission)
  • Registration failed silently if `instance` argument is `null` or `undefined`. (It shouldn't fail)
  • Actual value of `instance` argument is ignored; Gnash uses `_root` instead.


Problems with the underlying callback mechanism:

  • Gnash only pass maximum 3 arguments to the callback; specifiying more than 3 will have same result as passing 0 argument.
  • When the callback is called and returned no value or returned `undefined`, Gnash returns `null` to JavaScript instead.
  • Gnash passes Array and Object argument (including associative array) to the callback as `undefined`.
  • Gnash passes callback return value of type Array or Object back to JavaScript as a weird inaccessible "NPObject JS wrapper" object, and caused the plugin to crash.


Gnash: 0.8.11dev (git 6b269f9 24-May-2015) NPAPI
Adobe Flash Player: 11.2 r202 (11.2.202.491) NPAPI binary
Browser: Iceweasel 10.0.12 (debian)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Tue 04 Aug 2015 11:35:01 AM UTC, comment #3: 

This is an excellent bug report, I really hope to find the time to deal with it, but being extremely busy it would help if you could turn your test into a self-contained one (see other tests under testsuite/misc-mtasc.all) and ideally provide a patch to fix the code (doesn't sound too hard now that you found the culprit)

Sandro Santilli <strk>
Group Member
Tue 04 Aug 2015 11:08:16 AM UTC, comment #2: 

This issue is still reproducible under current git version of Gnash.

The root cause of this issue seems to be that Gnash uses the first argument in
`ExternalInterface.addCallback(methodName,instance,method)` to make the browser
aware of the registered callback, *but not using it to look up for a real
ActionScript function to call*.

Instead, Gnash tries to call `_root.methodName`, which is incorrect.


I've created HTML file and test flash file (using MTASC) to demonstrate the
root cause, by using two anonymous function, one registered as
ExternalInterface call named `script_call`, another one assigned to a variable
`_root.script_call`.



When running `js2flash-rootcb.html` on browser with Adobe Flash Player:

callee: starting
callee: adding ExternalInterface callback
callee: adding _root.script_call callback
caller: _root.script_call: function
callee: finished initializing
callee: entering ExternalInterface callback
callee: ExternalInterface callback succeeded, expected (Hello,World) got (Hello,World)
callee: ExternalInterface callback finished

After 3 sec, you'd see that ExternalInterface-registered callback is called correctly.

When running `js2flash-rootcb.html` on browser with Gnash current 0.8.11dev git:

68 TRACE: callee: starting
68 TRACE: callee: adding ExternalInterface callback
68 TRACE: callee: adding _root.script_call callback
68 TRACE: caller: _root.script_call: function
68 TRACE: callee: finished initializing
2963 TRACE: callee: entering _root.script_call callback
2963 TRACE: callee: _root.script_call callback succeeded, expected (Hello,World) got (Hello,World)
2963 TRACE: callee: _root.script_call callback finished

After 3 sec, you'd see that callback in _root is called instead of ExternalInterface-registered one.

Test Flash/HTML file, source code, build scripts and full debug logs with
screenshots of both cases are attached (js2flash-rootcb.zip).


Gnash: 0.8.11dev (git 6b269f9 24-May-2015) NPAPI
Adobe Flash Player: 11.2 r202 (11.2.202.491) NPAPI binary
Browser: Iceweasel 10.0.12 (debian)
System: Debian GNU/Linux 7.0 Wheezy i386


(file #34574)

Nutchanon Wetchasit <nachanon>
Tue 19 Mar 2013 10:45:16 AM UTC, comment #1: 

This problem still persists on current 0.8.11-git build
with exactly same trace message.

Gnash: Gnash 0.8.11dev master-21707-b482bd6 with 80989fcd, dfba5258 and 4b3dae97 reverted.
Browser: iceweasel 3.0.6-3 from Debian main repository (no addons)
System: Debian GNU/Linux 5.0 Lenny on i386

Nutchanon Wetchasit <nachanon>
Thu 30 Aug 2012 09:09:26 AM UTC, original submission:  

This is a spin-off from bug #37008 (SoundCloud issue).

I've tried to call my test flash's method from JavaScript land,
using Flash 8-style ExternalInterface callback that's expected
to recieve the parameters "Hello" and "World" from JavaScript land,
and return "Too" back to the JavaScript land.

The ActionScript callback method was coded like this

public function scriptCalled(arg1,arg2):String {

        trace("callee: callback entered");

        if(arg1=="Hello" && arg2=="World") {

                trace("callee: callback succeeded, expected (Hello,World) got (Hello,World)");

                calledbackindicator.gotoAndStop(2);

        } else {

                trace("callee: external called back incorrectly, expected (Hello,World) got ("+arg1+","+arg2+")");

        }

        trace("callee: callback finished");

        return "Too";

}


The callback was invoked correctly under Adobe Flash Player (with proper security settings),
but doesn't under Gnash.

This is a trace output from Adobe Flash Player 11:

callee: load
callee: finished loading
status: load
status: finished loading
status: load
status: finished loading
callee: first run
callee: external initializing
callee: adding callback
callee: finished first run
callee: callback entered
callee: callback succeeded, expected (Hello,World) got (Hello,World)
callee: callback finished

You may see that the ActionScript callback function was invoked.

This is a trace output result from Gnash:

2929:1] 292 TRACE: callee: load
2929:1] 292 TRACE: callee: finished loading
2929:1] 292 TRACE: callee: first run
2929:1] 292 TRACE: callee: external initializing
2929:1] 293 TRACE: callee: adding callback
2929:1] 294 TRACE: callee: finished first run
2929:1] 384 TRACE: status: load
2929:1] 384 TRACE: status: finished loading
2929:1] 384 TRACE: status: load
2929:1] 384 TRACE: status: finished loading

You may see that the ActionScript callback was not invoked.
From JavaScript perspective, the call returns null.


Note that a group of lines like this appeared in the log every time that I tried to call this ExternalInterface callback
(The "121 bytes" part of the log was consistent; it's always 121)

2929:1] 2796 DEBUG: There are 121 bytes in the network buffer
2929:1] 2796 DEBUG: bool gnash::movie_root::processInvoke(gnash::ExternalInterface::invoke_t*) enter
2929:1] 2796 DEBUG: Processing script_call call from the Browser.
2929:1] 2796 DEBUG: bool gnash::movie_root::processInvoke(gnash::ExternalInterface::invoke_t*) returning

Full Gnash debug log (verbosity = 2), also attached here.
http://www.mediafire.com/?db433qgumndy3dy

This is my test flash file and source, accompanied with HTML page,
created from Adobe Flash CS3 with Flash 8 target, also attached here.
http://www.mediafire.com/?3c9737f29embsis


Gnash: gnash 0.8.10-1~lenny, browser-plugin-gnash 0.8.10-1~lenny (both from getgnash.org APT repository)
Browser: iceweasel 3.0.6-3 from Debian main repository (no addons)
System: Debian GNU/Linux 5.0 Lenny on i386

Nutchanon Wetchasit <nachanon>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #36563:  js2flash-nothis-v2.zip added by nachanon (30KiB - application/zip - Test Flash/HTML file on `undefined`/`null` instance case (with property-based checks), debug logs and screenshots)
file #36557:  js2flash-nothis.zip added by nachanon (25KiB - application/zip - Test Flash/HTML file on `undefined`/`null` instance case, with debug logs and screenshots)
file #35071:  js2flash-auto-v2.tar.gz added by nachanon (16KiB - application/x-gzip - Example automated version of `js2flash-rootcb.html`, with HTML container)
file #35064:  js2flash-auto.tar.gz added by nachanon (15KiB - application/x-gzip - Example automated version of `js2flash-rootcb.html`)
file #34574:  js2flash-rootcb.zip added by nachanon (7KiB - application/zip - Test Flash/HTML file on _root callback case, with debug logs and screenshots)
file #26447:  js2flash.zip added by nachanon (3KiB - application/zip - Test flash file, source code and Gnash debug log)
file #26448:  iceweasel3.0-gnash0.8.10-js2flash.log.txt added by nachanon (4KiB - text/plain - Test flash file, source code and Gnash debug log)

 

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 nachanon (Voted in favor of this item)
  • -email is unavailable- added by nachanon (Submitted the item)
  •  

    There are 25 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 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-03-07 nachanon Attached File- Added js2flash-nothis-v2.zip, #36563
    2016-03-05 nachanon Attached File- Added js2flash-nothis.zip, #36557
    2015-10-05 nachanon Attached File- Added js2flash-auto-v2.tar.gz, #35071
    2015-10-05 nachanon Attached File- Added js2flash-auto.tar.gz, #35064
    2015-08-16 strk StatusIn Progress Ready For Test
    2015-08-16 strk Assigned toNone strk
    2015-08-16 strk StatusNone In Progress
    2015-08-04 nachanon Attached File- Added js2flash-rootcb.zip, #34574
    2013-03-11 nachanon Carbon-Copy- Added nachanon
    2012-08-30 nachanon Attached File- Added js2flash.zip, #26447
        Attached File- Added iceweasel3.0-gnash0.8.10-js2flash.log.txt, #26448

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code