Open Bug 1187425 Opened 10 years ago Updated 3 years ago

"Unloading" Framescript via "broadcastAsyncMessage" does not work (race condition)

Categories

(Core :: General, defect)

defect

Tracking

()

People

(Reporter: Manuel.Spam, Unassigned)

Details

The wiki says it shouldn't happen, but at least for me it happens. My simple addon uses the "global message manager" to load a frame script in "startup" of bootstrap.js and sends a "unload message" using "broadcastAsyncMessage", using the global message manager again, in "shutdown". In the frame script I do my cleanup as soon as the message arrives. For the following log (done with nightly. Latest stable gives similar result) I created my XPI without the leading "2" in the log messages first and started Firefox with this XPI. Then I modified the messages (leading "2" added) and installed this XPI into the running Firefox. This is what I came up with: console.log: bootstrap.js startup: 1 console.log: framescript.js startup console.log: framescript.js startup console.log: framescript.js startup console.log: framescript.js startup <<< here I do my installing of the modified XPI console.log: bootstrap.js shutdown: 8 console.log: framescript.js shutdown console.log: 2 bootstrap.js startup: 8 console.log: 2 framescript.js startup console.log: 2 framescript.js startup console.log: 2 framescript.js startup console.log: framescript.js shutdown console.log: 2 framescript.js shutdown console.log: framescript.js shutdown console.log: 2 framescript.js shutdown So Firefox starts my Addon first. As soon as I install my "new version", the "running version" gets the "shutdown" event. This is where I call broadcastAsyncMessage. One instance of my framescript immediately receives this message. Then "startup" of the "new XPI" is called and the new framescript instances get their "go". But after that not only the last few "old framescript instances" get the "unload message", but the new ones receive it, too... What is going wrong here? Any idea for a workaround?
Summary: "Unloading" Framescript via "sendAsyncMessage" does not work (race condition) → "Unloading" Framescript via "broadcastAsyncMessage" does not work (race condition)
Looks like bug 1202125 is a duplicate.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.