Closed
Bug 416886
Opened 17 years ago
Closed 17 years ago
JavaScript components in extensions should be registered last
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla1.9beta4
People
(Reporter: Brade, Assigned: benjamin)
References
Details
(Keywords: regression)
Attachments
(5 files, 3 obsolete files)
|
57.81 KB,
text/plain
|
Details | |
|
2.29 KB,
patch
|
dougt
:
review+
mtschrep
:
approval1.9+
|
Details | Diff | Splinter Review |
|
1.68 KB,
patch
|
benjamin
:
review+
beltzner
:
approval1.9+
|
Details | Diff | Splinter Review |
|
6.98 KB,
application/x-jar
|
benjamin
:
review+
|
Details |
|
11.67 KB,
patch
|
Details | Diff | Splinter Review |
I have a Firefox extension that includes a JavaScript component that registers its own JavaScript global property handler (overriding one provided by Firefox). In Firefox 2, my component is always registered after all of the Firefox components and everything works fine. In Firefox 3, my component is registered before the Firefox component it is trying to replace.
I believe that JavaScript components in extensions should be registered last. I added some debug logging to a trunk build; I am attaching a log file that shows the problem.
Possibly this regression occurred due to the fix for bug 415988. If you look at my debug log, you will see that all of the JS components are handled as "leftovers" (presumably because the JS loader is not there the first time registration is attempted). Since the leftovers array is processed in reverse order, it causes registration to occur in the wrong order.
| Reporter | ||
Comment 1•17 years ago
|
||
Search for MYEXT in the log file to quickly locate the relevant portion of the log.
| Assignee | ||
Comment 2•17 years ago
|
||
Interesting. Does this same problem occur in libxul or static builds? I think a simple solution might be to process the deferred components in forward order, but I want to make sure that in libxul builds we don't go into the slow-deferred codepath for JS components.
Comment 3•17 years ago
|
||
I tried a libxul build and did not see much difference (all of the JS modules are still handled as leftovers). What do you mean by "the slow-deferred codepath for JS components?"
| Assignee | ||
Comment 4•17 years ago
|
||
The design goal was that binary and JS components would be loaded on the first pass. If an extension was enabled that provided another component loader (e.g. python or java) those would go in the deferred list and be registered later. If JS components are ending up in the deferred list we should fix that. The deferred list uses extra allocations and would be slower than registering immediately.
| Assignee | ||
Comment 5•17 years ago
|
||
This should fix both problems. At least in libxul and static builds, we should now correctly load JS components the first time around, instead of sticking them all in the leftover list.
And, this processes the leftover list in forwards order instead of backwards order, so that components which end up there still have a hope of being in a sane order.
Attachment #303812 -
Flags: review?(dougt)
| Assignee | ||
Comment 6•17 years ago
|
||
This is a regression against 1.8 which makes it a lot harder for extensions to insert themself into the app... I think it should block especially since the fix is pretty trivial.
Flags: blocking1.9?
Comment 7•17 years ago
|
||
I think dougt only watches his dougt@meer.net account. He really should
consolidate!
Updated•17 years ago
|
Attachment #303812 -
Flags: review?(dougt) → review?(dougt)
Comment 8•17 years ago
|
||
Comment on attachment 303812 [details] [diff] [review]
Re-get component loaders after loading static modules, rev. 1
we should move the aLeftovers.Count() outside the loop. (unless inlining will get rid of the function call)
So, we call GetAllLoaders() so that we find any module-loader's that might be in static module.
It seams that:
a) the comment should apply to any module loader, and not specifically call out JS or use JS as an example:
in static and libxul builds, we might find a module loader in the static module. Set it up now, so that those components don't go into the leftovers list.
b) it seams sort of terrible that every time we go through autoregistration we have to worry about the mStaticModuleLoader. It seams that this should be done at InitXPCOM() instead of AutoRegister()
Fix the loop, and comment. Let me know about the AutoRegister() having to worry about the static module.
Attachment #303812 -
Flags: review?(dougt) → review-
| Assignee | ||
Comment 9•17 years ago
|
||
The only way to move aLeftovers.Count() outside the loop is if you manually decrement it when you successfully register a leftover component, and I really don't think the extra overhead of keeping the two in sync is worthwhile.
The JS component loader is the only loader in the static component list because that's the only one we ship. Any others (python/java) would be shipped as extra components/extensions.
Comment 10•17 years ago
|
||
this code doesn't know what we ship; I can build python into the static module, right?
Comment 11•17 years ago
|
||
Comment on attachment 303812 [details] [diff] [review]
Re-get component loaders after loading static modules, rev. 1
>- for (PRInt32 i = aLeftovers.Count() - 1; i >= 0; --i) {
>+ for (PRInt32 i = 0; i < aLeftovers.Count(); ++i) {
> nsresult rv = AutoRegisterComponent(aLeftovers[i], aDeferred,
> minLoader);
> if (NS_SUCCEEDED(rv))
> aLeftovers.RemoveObjectAt(i);
> }
Won't it cause problems to use a forward enumerating for loop in this case (since RemoveObjectAt() is called inside the loop)?
| Assignee | ||
Comment 12•17 years ago
|
||
Yes, I saw that today... I'll post a new patch Tuesday.
| Assignee | ||
Comment 13•17 years ago
|
||
Attachment #303812 -
Attachment is obsolete: true
Attachment #303970 -
Flags: review?(dougt)
Updated•17 years ago
|
Attachment #303970 -
Flags: review?(dougt) → review?(dougt)
Updated•17 years ago
|
Attachment #303970 -
Flags: review?(dougt) → review+
| Assignee | ||
Updated•17 years ago
|
Attachment #303970 -
Flags: approval1.9?
Updated•17 years ago
|
Flags: blocking1.9? → blocking1.9+
Updated•17 years ago
|
Attachment #303970 -
Flags: approval1.9? → approval1.9+
| Assignee | ||
Comment 14•17 years ago
|
||
Fixed on trunk for beta4.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9beta4
| Reporter | ||
Comment 15•17 years ago
|
||
Reopening bug. We encountered this same problem with a deferred component.
Proposed patch coming.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
| Reporter | ||
Comment 16•17 years ago
|
||
Attachment #307261 -
Flags: review?
| Reporter | ||
Updated•17 years ago
|
Attachment #307261 -
Flags: review?(dougt)
Attachment #307261 -
Flags: review?(benjamin)
Attachment #307261 -
Flags: review?
| Assignee | ||
Comment 17•17 years ago
|
||
Brade, which deferred component? AFAIK we don't use deferral in the core any more, so talk of deferred components makes me nervous.
| Reporter | ||
Comment 18•17 years ago
|
||
I ran into it with nsHelperAppDlg.js.in.
I see at least four occurrences that matter:
http://lxr.mozilla.org/seamonkey/search?string=FACTORY_REGISTER_AGAIN
Additionally, I'd fix nsSample.js in case people start with that file.
| Assignee | ||
Comment 19•17 years ago
|
||
Comment on attachment 307261 [details] [diff] [review]
proposed fix: preserve order when processing deferred components
Please file a followup bug on that list of components: I don't think any of them need deferring, and it will just slow us down a little or maybe more than a little.
Attachment #307261 -
Flags: review?(benjamin) → review+
| Reporter | ||
Updated•17 years ago
|
Attachment #307261 -
Flags: approval1.9?
| Reporter | ||
Comment 20•17 years ago
|
||
Bug #421286 was filed to address current deferred components.
Comment 21•17 years ago
|
||
Comment on attachment 307261 [details] [diff] [review]
proposed fix: preserve order when processing deferred components
Do we still need dougt's review here? If so, please renom once it's given. If not, please clear that review flag and renom.
Attachment #307261 -
Flags: approval1.9?
| Assignee | ||
Comment 22•17 years ago
|
||
Comment on attachment 307261 [details] [diff] [review]
proposed fix: preserve order when processing deferred components
no, his review is not necessary
Attachment #307261 -
Flags: review?(dougt) → approval1.9?
Comment 23•17 years ago
|
||
Comment on attachment 307261 [details] [diff] [review]
proposed fix: preserve order when processing deferred components
a1.9=beltzner
Attachment #307261 -
Flags: approval1.9? → approval1.9+
Comment 24•17 years ago
|
||
Comment on attachment 307261 [details] [diff] [review]
proposed fix: preserve order when processing deferred components
r- here: I want a test case before this goes in. Too much untested behaviour being depended on (apparently!) by external code, need to stop it somewhere and I'm saying it's here!
Hope we don't find out that some other extension was depending on the old order, as Brade's depends on the new order... :/
Attachment #307261 -
Flags: approval1.9+ → review-
| Assignee | ||
Updated•17 years ago
|
Keywords: checkin-needed
Comment 25•17 years ago
|
||
Comment #24 says this needs a test before it can land. This also isn't a blocker, so it needs approval before it can land.
Flags: in-testsuite?
Keywords: checkin-needed
| Reporter | ||
Comment 26•17 years ago
|
||
Attachment #311785 -
Flags: review?
| Reporter | ||
Comment 27•17 years ago
|
||
Attachment #311786 -
Flags: review?
Updated•17 years ago
|
Attachment #311785 -
Flags: review? → review?(benjamin)
Updated•17 years ago
|
Attachment #311786 -
Flags: review? → review?(benjamin)
| Assignee | ||
Comment 28•17 years ago
|
||
Comment on attachment 311785 [details] [diff] [review]
test case (part 1 of 2)
Woohoo!
Attachment #311785 -
Flags: review?(benjamin) → review+
| Assignee | ||
Updated•17 years ago
|
Attachment #307261 -
Flags: review-
| Assignee | ||
Updated•17 years ago
|
Attachment #311786 -
Attachment mime type: application/x-zip → application/x-jar
| Assignee | ||
Updated•17 years ago
|
Attachment #311786 -
Flags: review?(benjamin) → review+
| Assignee | ||
Comment 29•17 years ago
|
||
Comment on attachment 307261 [details] [diff] [review]
proposed fix: preserve order when processing deferred components
Re-requesting approval with the unit-tests below.
Attachment #307261 -
Flags: approval1.9?
Comment 30•17 years ago
|
||
Comment on attachment 307261 [details] [diff] [review]
proposed fix: preserve order when processing deferred components
a=beltzner
Attachment #307261 -
Flags: approval1.9? → approval1.9+
| Reporter | ||
Comment 31•17 years ago
|
||
Thanks for the reviews/approval. I landed the patch and new tests. When running the tests on Windows, I noticed that the Makefile was not passing a dos/windows-style path. This patch replaces the original Makefile diffs and fixes the tests on Windows.
| Reporter | ||
Updated•17 years ago
|
Status: REOPENED → RESOLVED
Closed: 17 years ago → 17 years ago
Resolution: --- → FIXED
| Reporter | ||
Comment 32•17 years ago
|
||
To fix a compile error in non-libXUL builds, I had to remove a #include "nsStringAPI.h" line from TestRegistrationOrder.cpp. I am attaching this patch to record here exactly what I checked in.
Attachment #311785 -
Attachment is obsolete: true
Attachment #312728 -
Attachment is obsolete: true
You need to log in
before you can comment on or make changes to this bug.
Description
•