Closed Bug 809888 Opened 12 years ago Closed 10 years ago

Create IPC thread for workers

Categories

(Core :: DOM: Workers, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: janv, Assigned: janv)

References

Details

Attachments

(1 file, 11 obsolete files)

      No description provided.
Blocks: SyncIDB
OS: Mac OS X → All
Hardware: x86 → All
Attached patch initial infrastructure (obsolete) — Splinter Review
We would like to reuse the existing IndexedDBParent implementation for sync IDB in workers. However, the event loop in workers can't handle IPC messages. A special shared IPC thread should be easier to implement, since it doesn't require fundamental changes in workers implementation.
Attached patch initial design (obsolete) — Splinter Review
Attachment #685593 - Flags: feedback?(bent.mozilla)
Attached file test.html (obsolete) —
Attached file worker.js (obsolete) —
Ok, so it seems that IPDL just works in this case too.

With the last patch, we are able to run this JS in workers:
var factory = new IDBFactorySync();
var db = factory.open("foo");
db.transaction("test", function(trans) {
  var store = trans.objectStore("test");
  var name = store.get(1);
});

Anyway, there's no handling of JS objects rooting in the patch yet.

Ben, we need your feedback here, if the implementation design is ok then Vendo can start implementing other sync IDB API methods and objects.
Attached patch initial design (obsolete) — Splinter Review
rebased patch
Attachment #685593 - Attachment is obsolete: true
Attachment #685593 - Flags: feedback?(bent.mozilla)
Attachment #686942 - Flags: feedback?(bent.mozilla)
Comment on attachment 685593 [details] [diff] [review]
initial design

Review of attachment 685593 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/indexedDB/ipc/PIndexedDB.ipdl
@@ +14,5 @@
>  namespace indexedDB {
>  
>  protocol PIndexedDB
>  {
> +  manager PBrowser or PContent or PWorker or PWorkers;

Just PWorker.

::: dom/ipc/PWorkers.ipdl
@@ +9,5 @@
> +
> +namespace mozilla {
> +namespace dom {
> +
> +rpc protocol PWorkers

I don't think we should have any sync (or rpc) messages in our worker protocols. The sync stuff should be handled in the worker through the use of sync queues.

Also, this should be something like PWorkerManagement or something.

@@ +17,5 @@
> +
> +parent:
> +    async PWorker();
> +
> +    PIndexedDB();

PIndexedDB should only be created from PWorker, not here.

::: dom/ipc/WorkerParent.h
@@ +15,5 @@
> +class WorkerParent : public PWorkerParent,
> +                     public nsISupports
> +{
> +public:
> +    NS_DECL_ISUPPORTS

This doesn't really need to be nsISupports, you just want refcounting, right?  NS_INLINE_DECL_REFCOUNTING

::: dom/webidl/DOMStringList_workers.webidl
@@ +11,5 @@
> + */
> +
> +interface DOMStringList_workers {
> +  readonly attribute unsigned long length;
> +  // XXXvarga getters seem to be not supported in workers

Let's make sure we have a bug filed on this.

::: dom/webidl/IDBFactorySync.webidl
@@ +5,5 @@
> + *
> + * The origin of this IDL file is http://www.w3.org/TR/IndexedDB/
> + */
> +
> +[Constructor]

The factory object should just exist at global scope, you shouldn't need to call 'new IDBFactorySync()'.

::: dom/workers/IDBObjectSync.h
@@ +23,5 @@
> +
> +class IndexedDBRequestWorkerChildBase;
> +class WorkerPrivate;
> +
> +class IDBObjectProxy

I don't really understand the purpose of this class or its derived classes. Why do we need an additional proxy object for each DOM object?

::: dom/workers/RuntimeService.cpp
@@ +1070,5 @@
>    }
>  
> +  mWorkersParent = new WorkersParent();
> +  mIPCThread = new Thread("WorkersIPCThread");
> +  mIPCThread->Start();

How does this thread stop?

::: dom/workers/WorkerScope.cpp
@@ +988,5 @@
>    }
>  
>    // Init other paris-bindings.
>    if (!FileReaderSyncBinding_workers::GetConstructorObject(aCx, global) ||
> +      !IDBFactorySyncBinding_workers::GetProtoObject(aCx, global) ||

You need to add the rest of these here, I think.
Depends on: 716631
Attachment #679685 - Attachment is obsolete: true
Attachment #686942 - Attachment is obsolete: true
Attachment #686942 - Flags: feedback?(bent.mozilla)
Attachment #703400 - Flags: feedback?(bent.mozilla)
Comment on attachment 703400 [details] [diff] [review]
Cleaned up patch (addressed most of the comments)

I have a new patch with alternative approach to release ipc thread objects.
Attachment #703400 - Flags: feedback?(bent.mozilla)
Attached patch patch (obsolete) — Splinter Review
Attachment #685594 - Attachment is obsolete: true
Attachment #685596 - Attachment is obsolete: true
Attachment #703400 - Attachment is obsolete: true
Attachment #704669 - Flags: feedback?(bent.mozilla)
Attached patch patch v0.1 (obsolete) — Splinter Review
I extracted IDB parts into a standalone patch which will be attached to bug 798875. So this patch only contains the IPC thread and PWorkerModule/PWorker protocols.
Assignee: nobody → Jan.Varga
Attachment #704669 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #704669 - Flags: feedback?(bent.mozilla)
Attachment #705273 - Flags: review?(bent.mozilla)
Attached patch up to date patch (obsolete) — Splinter Review
Attachment #705273 - Attachment is obsolete: true
Attachment #705273 - Flags: review?(bent.mozilla)
Attached patch patch v0.2 (obsolete) — Splinter Review
patch for review
Attachment #735580 - Attachment is obsolete: true
Attachment #772085 - Flags: review?(bent.mozilla)
Attached patch patch v 0.3 (obsolete) — Splinter Review
Attachment #772085 - Attachment is obsolete: true
Attachment #772085 - Flags: review?(bent.mozilla)
Attachment #827513 - Flags: review?(bent.mozilla)
Attached patch patch v 0.4Splinter Review
This one builds on windows.
Attachment #827513 - Attachment is obsolete: true
Attachment #827513 - Flags: review?(bent.mozilla)
Attachment #829383 - Flags: review?(bent.mozilla)
Is the need for this obviated by PBackground (bug 956218)?
(In reply to Andrew Overholt [:overholt] from comment #17)
> Is the need for this obviated by PBackground (bug 956218)?

Well, we'll see once IndexedDB on PBackground is implemented.
Can we close this bug?  Workers are running the IPC event loop.
Flags: needinfo?(bent.mozilla)
Yeah, it seems it would be better to update sync IDB to use all the new stuff (new event loop and PBackground) once it's ready, the extra IPC thread would make sense in case we don't have resources to update sync IDB implementation IMO.
I'm inclined to agree.
Flags: needinfo?(bent.mozilla)
Ok
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → WONTFIX
Attachment #829383 - Flags: review?(bent.mozilla)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: