bugGnash - The GNU Flash player - Bugs: bug #46131, Gnash's `ExternalInterface.call()`...

 
 

bug #46131: Gnash's `ExternalInterface.call()` did not correctly pass return value from JavaScript function

Submitter:  Nutchanon Wetchasit <nachanon>
Submitted:  Mon 05 Oct 2015 02:08:33 PM UTC
   
 
Category:  core Severity:  3 - Normal
Release:  master Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 08 Feb 2016 09:55:48 AM UTC, comment #9: 

Thanks

Sandro Santilli <strk>
Group Member
Sun 07 Feb 2016 01:37:24 PM UTC, comment #8: 

Yeah, this bug could now be marked as closed.
I'll follow the other return value problem as part of bug #47004.

Gnash: 0.8.11dev (git 435d3e9 6-Feb-2016)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Sat 06 Feb 2016 12:04:10 PM UTC, comment #7: 

Patch is applied, if nothing else is left to test here we can close the ticket.

Sandro Santilli <strk>
Group Member
Fri 05 Feb 2016 02:18:54 PM UTC, comment #6: 

An automated version of flash2js-multi test is now included, see patch #8905.

Gnash: 0.8.11dev (patched against git 02ec1e6 3-Feb-2015)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Tue 15 Dec 2015 08:25:52 AM UTC, comment #5: 

Patch applied, looking forward for tests to secure all these improvements.

Sandro Santilli <strk>
Group Member
Fri 09 Oct 2015 10:32:29 AM UTC, comment #4: 

Patch included, see patch #8765.

This is a trace log from `flash2js.html` after applied the patch:
+verbose+
67 ACTIONSCRIPT ERROR: reference to non-existent variable 'Flash2JS'
67 TRACE: flash2js: calling JavaScript function "flash_call"...
68 TRACE: flash2js: OK: JavaScript function correctly returned "Too"
-verbose-
You'd see that the return value from JavaScript is now propagated back
to ActionScript correctly.

This is a trace log from `flash2js-multi.html` after applied the patch:
+verbose+
65 ACTIONSCRIPT ERROR: reference to non-existent variable 'MultiFlash2JS'
67 TRACE: flash2js-multi: 1: OK: JavaScript function correctly returned "one"
67 TRACE: flash2js-multi: 2: OK: JavaScript function correctly returned "two"
68 TRACE: flash2js-multi: 3: OK: JavaScript function correctly returned "three"
68 TRACE: flash2js-multi: 4: OK: JavaScript function correctly returned "four"
69 TRACE: flash2js-multi: 5: OK: JavaScript function correctly returned "five"
69 TRACE: flash2js-multi: 6: OK: JavaScript function correctly returned "six"
70 TRACE: flash2js-multi: 7: OK: JavaScript function correctly returned "seven"
70 TRACE: flash2js-multi: 8: OK: JavaScript function correctly returned "eight"
71 TRACE: flash2js-multi: 9: OK: JavaScript function correctly returned "nine"
71 TRACE: flash2js-multi: 10: OK: JavaScript function correctly returned "ten"
72 TRACE: flash2js-multi: 11: OK: JavaScript function correctly returned "eleven"
72 TRACE: flash2js-multi: 12: OK: JavaScript function correctly returned "twelve"
73 TRACE: flash2js-multi: 13: OK: JavaScript function correctly returned "thirteen"
73 TRACE: flash2js-multi: 14: OK: JavaScript function correctly returned "fourteen"
74 TRACE: flash2js-multi: 15: OK: JavaScript function correctly returned "fifteen"
74 TRACE: flash2js-multi: 16: OK: JavaScript function correctly returned "sixteen"
75 TRACE: flash2js-multi: 17: OK: JavaScript function correctly returned "seventeen"
75 TRACE: flash2js-multi: 18: OK: JavaScript function correctly returned "eighteen"
76 TRACE: flash2js-multi: 19: OK: JavaScript function correctly returned "nineteen"
77 TRACE: flash2js-multi: 20: OK: JavaScript function correctly returned "twenty"
-verbose-

You'd see that all JavaScript return values are now correctly matched
its corresponding ExternalInterface call.

Note: There are more issues related to how Gnash (player) interprets
return value on special cases (like function that does not return value),
so this bug is not fully fixed yet.

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

Nutchanon Wetchasit <nachanon>
Fri 09 Oct 2015 09:21:55 AM UTC, comment #3: 

According to `doc/changelogs/ChangeLog-0.8.9`, this nonblocking behavior of
`ExternalInterface::readBrowser()` seems to be introduced by fe4faf3
in 0.8.9dev line, possibly to prevent freezes.

I think one way to fix this, is to re-introduce the old behavior of
`ExternalInterface::readBrowser()` that blocks until the expected data
is available or specified time runs out. (Gnash is supposed to wait for
the answer from browser as long as it takes, the timeout is just a
last-resort safeguard)

Fixing it this way shouldn't cause other problem as this method is not used
by any other code in Gnash.

Nutchanon Wetchasit <nachanon>
Thu 08 Oct 2015 06:37:35 AM UTC, comment #2: 

Also, this issue will get really messy if the SWF tried to use
`ExternalInterface.call()` multiple times in row, as leftover return values
from early calls will be mistakenly taken as result of later calls.

I have created a variant of test Flash file (using MTASC) that calls a
JavaScript function which returns an english reading of the number passed
as an argument. The function is called 20 times in a row to demonstrate
the problem. See the attached `flash2js-multi.zip`.

Following is a trace log from `flash2js-multi.html` on browser with Adobe Flash Player:

Warning: Reference to undeclared variable, 'MultiFlash2JS'
flash2js-multi: 1: OK: JavaScript function correctly returned "one"
flash2js-multi: 2: OK: JavaScript function correctly returned "two"
flash2js-multi: 3: OK: JavaScript function correctly returned "three"
flash2js-multi: 4: OK: JavaScript function correctly returned "four"
flash2js-multi: 5: OK: JavaScript function correctly returned "five"
flash2js-multi: 6: OK: JavaScript function correctly returned "six"
flash2js-multi: 7: OK: JavaScript function correctly returned "seven"
flash2js-multi: 8: OK: JavaScript function correctly returned "eight"
flash2js-multi: 9: OK: JavaScript function correctly returned "nine"
flash2js-multi: 10: OK: JavaScript function correctly returned "ten"
flash2js-multi: 11: OK: JavaScript function correctly returned "eleven"
flash2js-multi: 12: OK: JavaScript function correctly returned "twelve"
flash2js-multi: 13: OK: JavaScript function correctly returned "thirteen"
flash2js-multi: 14: OK: JavaScript function correctly returned "fourteen"
flash2js-multi: 15: OK: JavaScript function correctly returned "fifteen"
flash2js-multi: 16: OK: JavaScript function correctly returned "sixteen"
flash2js-multi: 17: OK: JavaScript function correctly returned "seventeen"
flash2js-multi: 18: OK: JavaScript function correctly returned "eighteen"
flash2js-multi: 19: OK: JavaScript function correctly returned "nineteen"
flash2js-multi: 20: OK: JavaScript function correctly returned "twenty"


You'll see that all return values are passed back to ActionScript correctly.

Following is a trace log from `flash2js-multi.html` on browser with Gnash:

60 ACTIONSCRIPT ERROR: reference to non-existent variable 'MultiFlash2JS'
61 TRACE: flash2js-multi: 1: failed: expected return value "one" got "undefined"
61 TRACE: flash2js-multi: 2: failed: expected return value "two" got "undefined"
61 TRACE: flash2js-multi: 3: failed: expected return value "three" got "undefined"
61 TRACE: flash2js-multi: 4: failed: expected return value "four" got "undefined"
61 TRACE: flash2js-multi: 5: failed: expected return value "five" got "undefined"
62 TRACE: flash2js-multi: 6: failed: expected return value "six" got "undefined"
62 TRACE: flash2js-multi: 7: failed: expected return value "seven" got "one"
62 TRACE: flash2js-multi: 8: failed: expected return value "eight" got "two"
62 TRACE: flash2js-multi: 9: failed: expected return value "nine" got "three"
62 TRACE: flash2js-multi: 10: failed: expected return value "ten" got "four"
62 TRACE: flash2js-multi: 11: failed: expected return value "eleven" got "undefined"
63 TRACE: flash2js-multi: 12: failed: expected return value "twelve" got "undefined"
63 TRACE: flash2js-multi: 13: failed: expected return value "thirteen" got "five"
63 TRACE: flash2js-multi: 14: failed: expected return value "fourteen" got "six"
63 TRACE: flash2js-multi: 15: failed: expected return value "fifteen" got "seven"
63 TRACE: flash2js-multi: 16: failed: expected return value "sixteen" got "eight"
64 TRACE: flash2js-multi: 17: failed: expected return value "seventeen" got "nine"
64 TRACE: flash2js-multi: 18: failed: expected return value "eighteen" got "undefined"
64 TRACE: flash2js-multi: 19: failed: expected return value "nineteen" got "undefined"
64 TRACE: flash2js-multi: 20: failed: expected return value "twenty" got "ten"


You'll see that return value of earlier ExternalInterface calls got mixed up
with later ones.

Screenshots, text output, full debug logs (verbosity 2 + action error log),
and container-player communication logs are also attached in the same ZIP file.

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

(file #35099)

Nutchanon Wetchasit <nachanon>
Wed 07 Oct 2015 04:28:00 PM UTC, comment #1: 

I have tested around, and this seems to be caused by buffer status check in
`ExternalInterface::readBrowser()` which is called by
`movie_root::callExternalJavascript()` to read the browser-returned value.

The buffer status check caused `ExternalInterface::readBrowser()` to
immediately return an empty string if the browser didn't respond instantly.
When this happened, `movie_root::callExternalJavascript()` didn't stick around
to wait for the return value, it simply passed the empty result back to
`ExternalInterface.call()` implementation, which returned `undefined` value
to ActionScript code.

The real return value message that eventually reached Gnash would be caught by
`movie_root::executeAdvanceCallbacks()` as a part of regular frame advancing
routine, then passed to `movie_root::processInvoke()`, and got discarded.

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

Nutchanon Wetchasit <nachanon>
Mon 05 Oct 2015 02:08:33 PM UTC, original submission:  

This is a spin-off from bug #46115 (host container message delimiter issue),
and bug #37223 (JavaScript-to-Flash ExternalInterface issue).

While I was testing on Gnash's container-player communication issue,
I have found that while Gnash's implementation of `ExternalInterface.call()`
calls JavaScript function with correct (String) arguments;
return value from JavaScript, however, is passed to ActionScript as `undefined`.

I have created a minimal Flash file (Flash 8) using MTASC, to demonstrate
the issue by calling a simple JavaScript function from ActionScript side.

Following is a trace log from `flash2js.html` on browser with Adobe Flash Player:

flash2js: calling JavaScript function "flash_call"...
flash2js: OK: JavaScript function correctly returned "Too"


You'd see that JavaScript is called and its String return value is passed correctly.

Following is a trace log from  `flash2js.html` on browser with Gnash:

TRACE: flash2js: calling JavaScript function "flash_call"...
TRACE: flash2js: failed: expected return value "Too", got "undefined"


You'd see that JavaScript's return value is passed to ActionScript code as `undefined`.

Test Flash file, build scripts, debug logs, plugin-player communication logs,
and screenshots are attached as `flash2js.zip`.

Note: This problem is likely to be originated from the player itself
(not libgnashplugin), as the return value string is correctly shown up
in container-to-player communication log.

Gnash: 0.8.11dev (git f0f66ce 23-Sep-2015) NPAPI
Flash Player: 11.2.202.491 NPAPI binary
Browser: Iceweasel 10.0.12 (debian)
System: Debian GNU/Linux 7.0 Wheezy 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 #35099:  flash2js-multi.zip added by nachanon (9KiB - application/zip - Test Flash file (for multiple calls issue), source code, logs, and screenshots)
file #35074:  flash2js.zip added by nachanon (6KiB - application/zip - Test Flash file, source code, logs, and screenshots)

 

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 (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-02-08 strk StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2015-12-15 strk StatusNone Ready For Test
    2015-10-08 nachanon Attached File- Added flash2js-multi.zip, #35099
    2015-10-05 nachanon Attached File- Added flash2js.zip, #35074

    Back to the top

    Powered by Savane 3.13-5884.
    Corresponding source code