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

Submitted by:  Nutchanon Wetchasit <nachanon>
Submitted on:  Mon 05 Oct 2015 02:08:33 PM UTC  
 
Category: coreSeverity: 3 - Normal
Release: masterStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

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

Thanks

Sandro Santilli <strk>
Project 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>
Project 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>
Project 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:

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:

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:

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:

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 File(s):
   
   
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
  • -unavailable- added by strk (Posted a comment)
  • -unavailable- added by nachanon (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 08 Feb 2016 09:55:48 AM UTCstrkStatusReady For Test=>Fixed
      Open/ClosedOpen=>Closed
    Tue 15 Dec 2015 08:25:51 AM UTCstrkStatusNone=>Ready For Test
    Thu 08 Oct 2015 06:37:35 AM UTCnachanonAttached File-=>Added flash2js-multi.zip, #35099
    Mon 05 Oct 2015 02:08:33 PM UTCnachanonAttached File-=>Added flash2js.zip, #35074

    Back to the top


    Powered by Savane 3.1-cleanup1