Closed Bug 554941 Opened 14 years ago Closed 14 years ago

[E10s] CPOW for synchronous TabChildGlobal messages

Categories

(Core :: IPC, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: smaug, Assigned: smaug)

References

Details

Attachments

(3 files, 1 obsolete file)

Attached patch patch (obsolete) — Splinter Review
This adds support for sending JS objects to TabChildGlobal's sendSyncMessage.

To not make nsFrameMessageManager to depend on IPC classes, 
TabParent::ReceiveMessage converts nsTArray<PObjectWrapperParent*>
to JS array so that message listeners can access objects using
message.objects array.

Note, I added a temporary hack to TabParent::GetGlobalJSObject. I'll file a followup to sort out what we want to do there.

All the message manager tests are still in test.xul. I'll mochitestify
those all soon.
Attachment #434875 - Flags: review?(bnewman)
Blocks: 554942
The important parts of the patch look good.  As discussed on IRC, I had some misgivings about the RequestRunToCompletion modifications.  Since it seemed easier to talk about those changes in terms of code, I'm posting an incremental patch that contains my suggestions.

See comment #2 for further explanation.
>+void
>+ContentProcessParent::ReportChildAlreadyBlocked()
>+{
>+    if (!mRunToCompletionDepth) {
>+#ifdef DEBUG
>+        printf("Running to completion...\n");
>+#endif
>+        mRunToCompletionDepth = 1;
>+        mShouldCallUnblockChild = false;
>+    }
>+}

There were a couple of things I didn't like about RunningToCompletion(bool).

First, the name was a little off.  We're really only saying the child is blocked right now, and thus the parent should not call BlockChild(), so I changed the name to ReportChildAlreadyBlocked() to reflect that intent.

Second, it seemed a little less than ideal that we had to call RunningToCompletion(bool) twice, taking care to call it with aRunning=false after all CPOW operations had finished.  This new version is used more like RequestRunToCompletion(): call it once before any CPOW operations happen, and the cleanup automatically happens later (specifically, resetting mRunToCompletionDepth without calling UnblockChild()).

Here's where that happens:

> ContentProcessParent::AfterProcessNextEvent(nsIThreadInternal *thread,
>                                             PRUint32 recursionDepth)
> {
>     if (mRunToCompletionDepth &&
>         !--mRunToCompletionDepth) {
> #ifdef DEBUG
>             printf("... ran to completion.\n");
> #endif
>-            UnblockChild();
>+            if (mShouldCallUnblockChild) {
>+                mShouldCallUnblockChild = false;
>+                UnblockChild();
>+            }
>     }

It seems a little easier to understand the intent of calling ReportChildAlreadyBlocked() if we do it in AnswersendSyncMessageToParent():

> bool
> TabParent::AnswersendSyncMessageToParent(const nsString& aMessage,
>                                          const nsString& aJSON,
>                                          const nsTArray<PObjectWrapperParent*>& aObjects,
>                                          nsTArray<nsString>* aJSONRetVal)
> {
>+  static_cast<ContentProcessParent*>(Manager())->ReportChildAlreadyBlocked();
>   return ReceiveMessage(aMessage, PR_TRUE, aJSON, &aObjects, aJSONRetVal);
> }

... instead of conditioning it on aSync in ReceiveMessage():

>-      // Because of rpc, child is already blocked if aSync.
>-      if (aSync) {
>-        ContentProcessParent::GetSingleton()->RunningToCompletition(true);
>-      }
>       manager->ReceiveMessage(mFrameElement,
>                               aMessage,
>                               aSync,
>                               aJSON,
>                               objectsArray,
>                               aJSONRetVal);
>-      if (aSync) {
>-        ContentProcessParent::GetSingleton()->RunningToCompletition(false);
>-      }
>     }
>   }
>   return true;
> }

Finally, what's with these &amp;'s in your event handler functions?

>-          if (m.objects.length == 3 &amp;&amp;
>-              m.objects[0].target.href == m.json.href &amp;&amp;
>-              m.objects[1] == 123 &amp;&amp;
>+          if (m.objects.length == 3 &&
>+              m.objects[0].target.href == m.json.href &&
>+              m.objects[1] == 123 &&
(In reply to comment #2)
> It seems a little easier to understand the intent of calling
> ReportChildAlreadyBlocked() if we do it in AnswersendSyncMessageToParent()
Ok.


> Finally, what's with these &amp;'s in your event handler functions?
That script isn't in CDATA, so && can't be used, or at least my editor (jEdit) complained about using &&.
And indeed after the &amp; -> & test.xul doesn't work at all.
I just changed & back to &amp;.
I will rewrite all those testcases for mochitest, and I'll add
then the <![CDATA[ ... ]]>
Assignee: nobody → Olli.Pettay
Attachment #434875 - Attachment is obsolete: true
Attachment #435188 - Flags: review?(bnewman)
Attachment #434875 - Flags: review?(bnewman)
Comment on attachment 435188 [details] [diff] [review]
patches merged, without &amp; -> & change

Looks good to me.

(In reply to comment #4)
> And indeed after the &amp; -> & test.xul doesn't work at all.

Whoa, crazy.  I knew there must have been a reason!
Attachment #435188 - Flags: review?(bnewman) → review+
http://hg.mozilla.org/projects/electrolysis/rev/731c8bfd876e
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Bizarre error on Windows.

e:/builds/moz2_slave/electrolysis-win32-debug/build/obj-firefox/ipc/ipdl/PIFrameEmbeddingChild.cpp(329) : error C2872: 'PContextWrapperChild' : ambiguous symbol
        could be 'e:/builds/moz2_slave/electrolysis-win32-debug/build/obj-firefox/ipc/ipdl/PIFrameEmbeddingChild.cpp(22) : mozilla::jsipc::PContextWrapperChild PContextWrapperChild'
        or 'e:\builds\moz2_slave\electrolysis-win32-debug\build\obj-firefox\ipc\ipdl\_ipdlheaders\mozilla/jsipc/PContextWrapperChild.h(59) : mozilla::jsipc::PContextWrapperChild'
e:/builds/moz2_slave/electrolysis-win32-debug/build/obj-firefox/ipc/ipdl/PIFrameEmbeddingChild.cpp(335) : error C2872: 'PContextWrapperChild' : ambiguous symbol
        could be 'e:/builds/moz2_slave/electrolysis-win32-debug/build/obj-firefox/ipc/ipdl/PIFrameEmbeddingChild.cpp(22) : mozilla::jsipc::PContextWrapperChild PContextWrapperChild'
        or 'e:\builds\moz2_slave\electrolysis-win32-debug\build\obj-firefox\ipc\ipdl\_ipdlheaders\mozilla/jsipc/PContextWrapperChild.h(59) : mozilla::jsipc::PContextWrapperChild'


I think this patch caused the problem. Backing out for now and fixing tomorrow.
http://hg.mozilla.org/projects/electrolysis/rev/497cb03bf371
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
I'll reopen if the fix doesn't work after all.
Status: REOPENED → RESOLVED
Closed: 14 years ago14 years ago
Resolution: --- → FIXED
Still no luck. The same bizarre error is there on Windows builds
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Depends on: 555573
http://hg.mozilla.org/projects/electrolysis/rev/1b9ac85bf4fd
Status: REOPENED → RESOLVED
Closed: 14 years ago14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: