roadlabs / chromiumembedded

Automatically exported from code.google.com/p/chromiumembedded
0 stars 1 forks source link

CefV8Context becomes NULL when executing a callback function once Chromedriver is plugged #1570

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Steps used to reproduce the problem are similar to what is described there: 
https://code.google.com/p/chromiumembedded/wiki/GeneralUsage#Custom_Implementati
on

What steps will reproduce the problem?
1. Register a javascript function using a callback in one of its parameters.
2. Connect through Chromedriver configured with remote debug port to the window.
3. Execute this function using a custom V8Handler to store the callback and 
context for a later use.
4. The render process sends an asynchronous IPC message to the browser process 
requesting that work be performed.
5. Upon completion of the work the browser process sends an asynchronous IPC 
message back to the render process with the result.
6. The render process receives the IPC message and try to executes the callback 
function with the result.

What is the expected output? What do you see instead?
We expect callback execution, instead stored context and function are NULL, so 
it crashes.

What version of the product are you using? On what operating system?
CEF3 branch 2171, Windows 8 64bits

Please provide any additional information below.
Without connecting through Chromedriver the whole process execute normally.

In attachment, please find patch to apply on cefsimple and the index.html used 
to highlight the issue. 

Original issue reported on code.google.com by tom.roui...@gmail.com on 6 Mar 2015 at 9:43

Attachments:

GoogleCodeExporter commented 9 years ago
Related forum post: http://magpcss.org/ceforum/viewtopic.php?f=6&t=12712

In the forum post you say:

> context is not null when executing CefV8Handler::Execute() for storing 
current context
> and callback function, but is null when using it after inter-processes 
communications,
> resulting in a crash when using Chromedriver while using callback functions.

Can you verify that V8Handler::Execute is called and that |context| and 
|function| are assigned values? Do you have multiple browsers in 
|browser_list_|?

You're not clearing the |context| and |function| values anywhere so they're 
likely either (a) not being assigned to begin with or (b) the calls to 
V8Handler::Execute and V8Handler::executeCallback are occurring in different 
renderer processes.

Original comment by magreenb...@gmail.com on 6 Mar 2015 at 3:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I added logs to the patch to show function and context ptr value.
Here is what is shown with my new logs:

> V8Handler::Execute() :
>     GetCurrentContext() is : not null
>     Storing function: not null
>     Storing context: not null
> 
> V8Handler::executeCallback() :
>     Stored context: context is null
>     Stored function: function is null

So V8Handler::Execute is called and |context| and |function| are both assigned 
values.

Running with the same logs but without connecting chromedriver, the output is:

> V8Handler::Execute() :
>     GetCurrentContext() is : not null
>     Storing function: not null
>     Storing context: not null
>
> V8Handler::executeCallback() :
>     Stored context: context is not null
>     Stored function: function is not null

|browser_list_| is left untouched from cefsimple, so when requiring a browser I 
use the first one from the list, expecting to get the main and only one.

Original comment by tom.roui...@gmail.com on 6 Mar 2015 at 4:01

GoogleCodeExporter commented 9 years ago
@#3: Is there anything else occurring between call to V8Handler::Execute() and 
V8Handler::executeCallback() (navigation, etc)? Can you print the current 
thread ID as part of the output from those functions?

Original comment by magreenb...@gmail.com on 6 Mar 2015 at 4:04

GoogleCodeExporter commented 9 years ago
Thread ID when executing both V8Handler::Execute() and 
V8Handler::executeCallback() is TID_RENDERER, chromedriver connected and not 
connected.

I'm not sure about what you are asking, but the only thing I'm doing is 
pressing the button (only element in my webpage), executing my function with a 
callback in its parameters, which trigger the usual IPC process.

But I can check if any other function are called in between, if that's why you 
are asking ?

Original comment by tom.roui...@gmail.com on 6 Mar 2015 at 4:19

GoogleCodeExporter commented 9 years ago
@#5: I'd like to verify that the renderer process is not changing between 
calls. Please include the output of base::PlatformThread::CurrentId() (from 
include/base/cef_platform_thread.h) in your print statements.

Original comment by magreenb...@gmail.com on 6 Mar 2015 at 4:25

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
@#6: Sorry for the delay. Printing this id show:

> V8Handler::Execute(): TID_RENDERER; current id: 3836
>     Storing function: not null
>     Storing context: not null
>
> V8Handler::executeCallback(): TID_RENDERER; current id: 3836
>     Stored function: function is null
>     Stored context: context is null

Furthermore, the problem occur after plugging and then executing anything with 
Chromedriver (just plug in does not result in this issue).

First execution with Chromedriver (such as printing currentUrl with 
getDriver().getCurrentUrl() or anything else) flicker the webview, as if it was 
refreshed or reloaded, but it is not.

Original comment by tom.roui...@gmail.com on 10 Mar 2015 at 1:54

GoogleCodeExporter commented 9 years ago
CEF is transitioning from Google Code to Bitbucket project hosting. If you 
would like to continue receiving notifications on this issue please add 
yourself as a Watcher at the new location: 
https://bitbucket.org/chromiumembedded/cef/issue/1570

Original comment by magreenb...@gmail.com on 14 Mar 2015 at 3:39