Closed
Bug 26516
Opened 25 years ago
Closed 24 years ago
java/plugins initialize at startup
Categories
(Core Graveyard :: Plug-ins, defect, P1)
Tracking
(Not tracked)
VERIFIED
FIXED
mozilla0.9
People
(Reporter: warrensomebody, Assigned: beard)
References
Details
(Keywords: perf, topperf)
Attachments
(7 files)
637 bytes,
patch
|
Details | Diff | Splinter Review | |
706 bytes,
patch
|
Details | Diff | Splinter Review | |
3.68 KB,
patch
|
Details | Diff | Splinter Review | |
4.53 KB,
patch
|
Details | Diff | Splinter Review | |
4.24 KB,
patch
|
Details | Diff | Splinter Review | |
7.80 KB,
patch
|
Details | Diff | Splinter Review | |
7.83 KB,
patch
|
Details | Diff | Splinter Review |
I've noticed that java initializes on startup, in fact all plugins do. It
appears that the plugins directory is iterated through during startup and all
the plugins are re-registered (in nsPluginHostImpl::GetPluginFactory). Since
plugins can now just be viewed as components, we should rely on the standard
component registration in xpcom to manage them. (Wasn't that the whole point of
the 4.x plugin adapters, etc.?)
nsPluginHostImpl::GetPluginFactory takes 4.07% of startup time after
eliminating idle times from Quantify, and time spent in LoadLibrary.
Reporter | ||
Updated•25 years ago
|
Updated•25 years ago
|
Whiteboard: [PDT+]
OJI is already an XPCOM service, and is registered as such. Java Plug-In is a
plugin that asks for the JVMManager XPCOM service. I think there might be a
couple of issues here, but Andrei Volkov is better equipped to answer this than
I. Here is my belief about the several issues:
1) Old-style plugins aren't loaded as components, so those plugins can't be
managed in the XPCOM way (e.g., Shockwave, RealAudio, etc.).
2) Java being initialized on startup is a different bug: I believe that
LiveConnect is causing the JVM to be started as a side-effect, a behavior which
we will fix after Beta1.
I believe that the basic bug as being reported here is "plugins initialize at
startup", so I'm re-assigning this to the Plugins module.
Assignee: drapeau → av
Component: OJI → Plug-ins
QA Contact: paw → shrir
Must land a fix for this by 02/23 or we will PDT- (not fix) for beta1.
Whiteboard: [PDT+] → [PDT+] Must land by 02/23
I am removing PDT+ mark since 02/25 passed and we do not have fix in hand yet.
Status: NEW → ASSIGNED
Whiteboard: [PDT+] w/b minus on 02/25 → w/b minus on 02/25
Putting on PDT- for beta1.
Whiteboard: w/b minus on 02/25 → [PDT-]w/b minus on 02/25
Plugins folder is iterated through looking for old school plugins, and those
should be registered at start up. The process on Windows should not be very
costy since actual dll's are not being loaded at this time. Java initializes
from LiveConnect, so I reassining to LiveConnect people to take a look.
Assignee: av → rogerl
Status: ASSIGNED → NEW
Component: Plug-ins → Live Connect
QA Contact: shrir → rginda
Comment 7•25 years ago
|
||
Ah yes, but LiveConnect initializes Java when OJI asks it to. What *exactly* is
the bug here, is Java demonstrably slower to start-up than 4X ?
Reporter | ||
Comment 8•25 years ago
|
||
The bug here is that java consumes memory footprint and startup time
unnecessarily. It should only get initialized when it's really needed, i.e.
when the first applet is loaded.
Comment 9•25 years ago
|
||
OK, then I don't think this is a LiveConnect issue. LiveConnect initializes the
JVM when requested to do so, which would be at the hands of OJI and drapeau has
already indicated that's a Plugin's issue. This finger++ is hardly productive
though - I'm happy to work with anybody to address this, I just don't see what
LiveConnect can do about it?
Reporter | ||
Comment 10•25 years ago
|
||
Yes, this is a plugins issue. Java is just the worst-case scenario.
Just make plugin initialization lazy.
Comment 11•25 years ago
|
||
Reassigning back to myself.
Assignee: rogerl → av
Component: Live Connect → Plug-ins
QA Contact: rginda → shrir
Reporter | ||
Comment 12•25 years ago
|
||
I just discovered bug 18277 which is a dup. Av - can you work with drapeau to
see who's going to own this?
Comment 13•25 years ago
|
||
2 betas would be better than one for shaking out major adjustments
to startup... putting on beta2 radar
Comment 14•25 years ago
|
||
Putting on [nsbeta2-] radar. av already overloaded with beta2 work. This is
work for beta3. Putting on nsbeta3 keyword radar.
Keywords: nsbeta3
Whiteboard: [PDT-]w/b minus on 02/25 → [nsbeta2-]
Comment 15•25 years ago
|
||
Reassigning to George, who's kindly volunteered to take this on. Thanks George!
Assignee: av → drapeau
Comment 17•25 years ago
|
||
M16 has been out for a while now, these bugs target milestones need to be
updated.
Comment 18•25 years ago
|
||
For the record, it looks like the only reason the plugins dir is traversed on
startup is for LiveConnect:
nsPluginsDir::nsPluginsDir(unsigned short 1) line 193
nsPluginHostImpl::LoadPlugins(nsPluginHostImpl * const 0x0154f644) line 2605 +
10 bytes
nsPluginHostImpl::GetPluginFactory(nsPluginHostImpl * const 0x0154f644, const
char * 0x01f6f684, nsIPlugin * * 0x0012fa24) line 2421
nsJVMManager::StartupJVM() line 567 + 32 bytes
nsJVMManager::MaybeStartupLiveConnect() line 741 + 20 bytes
nsJVMManager::StartupLiveConnect(nsJVMManager * const 0x0154e988, JSRuntime *
0x00c6acf8, int & 0) line 128 + 11 bytes
nsJSEnvironment::nsJSEnvironment() line 1291 + 49 bytes
nsJSEnvironment::GetScriptingEnvironment() line 1236 + 27 bytes
NS_CreateScriptContext(nsIScriptGlobalObject * 0x0154d260, nsIScriptContext * *
0x01548880) line 1331 + 5 bytes
nsDocShell::EnsureScriptEnvironment(nsDocShell * const 0x015487d0) line 3825 +
50 bytes
nsWebShell::GetInterface(nsWebShell * const 0x015487f4, const nsID & {...},
void * * 0x0012fbf8) line 545 + 19 bytes
nsGetInterface::operator()(const nsID & {...}, void * * 0x0012fbf8) line 37 +
31 bytes
nsCOMPtr<nsIDOMWindow>::assign_from_helper(const nsCOMPtr_helper & {...}, const
nsID & {...}) line 856 + 18 bytes
nsCOMPtr<nsIDOMWindow>::nsCOMPtr<nsIDOMWindow>(const nsCOMPtr_helper & {...})
line 553
nsAppShellService::GetHiddenWindowAndJSContext(nsAppShellService * const
0x01560550, nsIDOMWindow * * 0x0012fca8, JSContext * * 0x0012fcac) line 687 +
32 bytes
nsAppShellService::CreateHiddenWindow(nsAppShellService * const 0x01560550)
line 223 + 40 bytes
main1(int 2, char * * 0x00c74090, nsISupports * 0x00000000) line 881
main(int 2, char * * 0x00c74090) line 1099 + 37 bytes
mainCRTStartup() line 338 + 17 bytes
KERNEL32! 77f1b304()
If you disable Java using the Preferences Advanced option, the plugins dir
doesn't get traversed at startup. Thus I feel the correct thing to do would be
to modify the nsJSEnvironment constructor to move the call to
JVMManager::StartupLiveConnect() until it's actually needed. Can someone
please tell what I would need to change to do this?
Thanks,
Ed
Assignee: drapeau → edburns
Status: ASSIGNED → NEW
Reporter | ||
Comment 21•25 years ago
|
||
I say yank it out of there. We don't do liveconnect now, and probably never will
(given that it's JRI-based, i.e. dependent on the old netscape jvm).
Reporter | ||
Comment 23•25 years ago
|
||
Liveconnect is based on JRI and is not part of your JVM. AFAIK, it has never
worked in seamonkey, and never will.
Comment 24•25 years ago
|
||
Jeff Dyer needs to comment on this one. I believe he *did* have LiveConnect
support working. Just in case, I'm adding him to the CC list on this so he can
reply.
Comment 25•25 years ago
|
||
LiveConnect for JNI is implemented. The JRI based code was ported to JNI
sometime last year. It has been working ever since, except as reported in
Bugzilla.
> AFAIK, it has never worked in seamonkey, and never will.
Perhaps you know something I don't.
Reporter | ||
Comment 26•25 years ago
|
||
I only meant the JRI one would never work. I had forgotten that it got ported to
JNI. Sorry for the confusion.
Comment 27•25 years ago
|
||
Warren: no problem, that's cool, but we still could use some advice about how to
fix the bug so that the JVM gets requested to start up only at the moment it's
needed, not sooner. If you know anybody who can help, that would be great.
Otherwise, I will probably ask Jeff Dyer to help on this one, and he won't be
able to get to it right away because he's working on the completion of
Java-to-JavaScript security right now.
Comment 28•25 years ago
|
||
ETA 28 July 2000
Comment 29•25 years ago
|
||
Comment 30•25 years ago
|
||
The Java Plugin is registered on startup time, i.e.
nsPluginHostImpl::GetPluginFactory
nsJVMManager::StartupJVM
nsJVMManager::MaybeStartupLiveConnect
nsJVMManager::StartupLiveConnect
nsJSEnvironment::nsJSEnvironment
The Java Plugin is also registered when an applet is
loaded. If the Java Plugin is installed, I see
nsPluginHostImpl::GetPluginFactory
nsPluginHostImpl::SetUpPluginInstance
nsPluginHostImpl::InstantiateEmbededPlugin
and the debugging message
"For application/x-java-vm found plugin
C:\mozilla\dist\WIN32_D.OBJ\bin\plugins\NPJava32.dll"
If the Java Plugin is not installed, I see
nsPluginHostImpl::GetPluginFactory
nsPluginHostImpl::SetUpDefaultPluginInstance
nsPluginHostImpl::InstantiateEmbededPlugin
and message
"For * found plugin
C:\mozilla\dist\WIN32_D.OBJ\bin\plugins\npnul32.dll"
The proposed fix here is to modify
nsJVMManager::StartupJVM
so that the Java Plugin is not registered on startup,
see the attachment at 7/18/00.
For the plugins other than Java Plugin, I checked QTV plugin with URL,
http://www.apple.com/trailers/paramount/mission_impossible_2/bts_med.html
With/Without my fix, the
nsPluginHostImpl::GetPluginFactory
is not called at startup time. It is called when I load the page and
I see the message,
"For video/quicktime found plugin
C:\mozilla\dist\WIN32_D.OBJ\bin\plugins\npqtplugin.dll"
I am not sure if there is other method to register QTV plugin at
startup time.
According George.Drapeau@eng.sun.com, the issue of not loading JVM at
the startup time will be addressed at Bug 18277.
Reporter | ||
Comment 31•25 years ago
|
||
Cc'ing waterson.
Comment 32•25 years ago
|
||
I'm currently building. I'll try this when it's built.
Comment 33•25 years ago
|
||
I like the simplicity of this fix, but it breaks the Menu function "Tasks-
>Tools->Java Console". This fix prevents the body of StartupJVM from ever
executing. This needs to execute to enable the Java Console to work.
Comment 34•25 years ago
|
||
Comment 35•25 years ago
|
||
Thank Ed for caching up the problem of Menu function for
Java Console in my proposed fix. I tested your second
iteration in following steps,
Step 1. start mozilla which loading http://www.mozilla.org
Step 2. load an applet, e.g.
http://192.9.48.9/products/plugin/1.3/demos/applets/CardTest/example1.html
Step 3. select menu "Tasks->Tools->Java Console" which starting
Java Console.
Everything works fine and the method
nsPluginHostImpl:GetPluginFactory.
is not called on startup.
However, the Java Console doesn't start and I saw memory error in
nsJVMManager::ShowJavaConsole(nsJVMManager * const 0x00d93c70) line 146
if I skip the step 2 above.
Comment 36•25 years ago
|
||
It looks like the patch #2 will block nsJVMManager::MaybeStartupLiveConnect from
ever starting the vm. The problem is that Liveconnect and JVM initializiation
are entangled. And, that there is code that depends on a running vm, that
doesn't know how to start it. The solution (apparently) was just to start the vm
at when the browser loads whether it is needed or not. Bug 27462 is another
reason why this is a bad idea. The general solution requires that the vm not be
started before it is needed (as is being done in the fix proposed here), and
also that code that depends on the vm running, make it run (this part is
missing from the proposed solutions).
Comment 37•25 years ago
|
||
Jeff, can you please give me some pointers on how to do the second part
of what you propose: "code that depends on the vm running, make it run"?
Something of the form of filename/line-number pairs or even just class names
would be great.
Thanks,
Ed
Comment 38•25 years ago
|
||
I'd start by factoring out LiveConnect and start the vm directly from those
places where a running vm (without liveconnect) is needed. Once this is working
properly, you can do the same for LiveConnect.
Hope that helps to get you pointed in the right direction. Let me know if you
want more help.
Comment 40•24 years ago
|
||
Marking mozilla0.9. All tries to reduce mozilla memory footprint are totally
useless if Java is adding 7 MB of RAM bloat at each startup. This prevents Java
enabled small embedded browsers as well. Please reconsider priority of this bug.
Keywords: mozilla0.9
Comment 42•24 years ago
|
||
*** Bug 42262 has been marked as a duplicate of this bug. ***
Comment 43•24 years ago
|
||
reassign to joe
Assignee: edburns → joe.chou
Status: ASSIGNED → NEW
Priority: P3 → P1
Comment 44•24 years ago
|
||
*** Bug 18277 has been marked as a duplicate of this bug. ***
Comment 45•24 years ago
|
||
Joe, any status?
Comment 46•24 years ago
|
||
I have not got a chance to look at this one closely yet. I'll look at it
tomorrow.
Comment 47•24 years ago
|
||
Jeff, would you be a little more specific about your second part of suggestions?
Comment 48•24 years ago
|
||
>------- Additional Comments From Jeff Dyer 2000-07-20 12:57 -------
>
>I'd start by factoring out LiveConnect and start the vm directly from those
>places where a running vm (without liveconnect) is needed. Once this is working
>properly, you can do the same for LiveConnect.
All I mean is find the places that the JVM is needed and initialize the Java
plugin when execution reaches those places. Then find all the places where
Livecconect is needed and initialize Liveconnect when execution reaches those
places.
Before I'd mess with the code though, I'd do a top-down review of the design to
see if there is a need to revise the way either of these components are started.
For example, I'd look for any dependencies that force LC to start when the VM is
started.
Comment 49•24 years ago
|
||
To my understanding, with today's build on Windows, in
nsJVMManager::MaybeStartupLiveConnect(void) we make a call to
JSJ_ConnectToJavaVM(NULL, NULL) which causes java to start.
Specifically, in JSJ_ConnectToJavaVM(NULL, NULL), we check if we hava a Java VM
and if we do, we call
JSJ_callbacks->create_java_vm(&java_vm, &jEnv, initargs)
which starts Java (and the little guy in the system tray).
Can this somehow be differed untill needed? It's probably a huge memory and
performance gain to lazily start Java.
Target milestone is set for M18, I nominate Mozilla 0.9?
Comment 50•24 years ago
|
||
Yeah, this bug needs a valid Target Milestone. Joe?
/be
Comment 52•24 years ago
|
||
Changed milestone from m18 to mozilla0.9.
Target Milestone: M18 → mozilla0.9
Updated•24 years ago
|
Comment 53•24 years ago
|
||
this bug has such a long and sorted history....
wondering if the fix for this is well understood and on track for 0.9?
Comment 54•24 years ago
|
||
Yes, Mozilla0.9 is too soon for this fix (which is planned to be release on 19th
of March?). Based on Jeff's suggestions, the fix seems to have multiple changes,
and requires more time to test as well. I've been working on some urgent bugs
recently, and I need to change the milestone to Mozilla0.9.1. Any objections?
Comment 55•24 years ago
|
||
My only comment is that it's a high priority to improve startup as
soon as we can. The faster we can get to this bug the better.
Comment 56•24 years ago
|
||
Why not leave this at 0.9 for now -- we're seriously contemplating a numbering
change to make the current milestone be 0.8.1 (announcements and roadmap update
soon), and I'd hate to take pressure off this bug, or even fiddle with its
fields for no gain.
/be
Comment 57•24 years ago
|
||
Comment 58•24 years ago
|
||
This patch attempts to skip the loading of Java from the plugin point of view,
as if the libraries weren't in the folder. Check about:java and they aren't
even registered. However, now that nsPluginHostImpl::ReloadPlugins() works, I
set flags to trip skip loading until it finds the Java mime-type.
However, there are a few bugs left like it calls ReloadPlugins twice and the
Java Console Menu Item stays disabled.
Also, I haven't tested this patch extensivly, I don't know what I broke
(LiveConnect, which I was told does not work anyway, perhaps?). Seems to save
loading time and memory on my system.
Comment 59•24 years ago
|
||
LiveConnect *does* work; not completely, but we're fixing LiveConnect bugs as we
encounter them.
Shrirang or Raju, can either of you point Peter to some LiveConnect tests that
he could try with his patched build?
Comment 60•24 years ago
|
||
Most of the Test case we have are inside SUN. Not sure if Peter would be able to
access those.
There are some on the mozilla site (mayb devlped by Shrirang).
http://www.mozilla.org/quality/browser/front-end/testcases/oji/
He should be able to find some tests there.
Comment 61•24 years ago
|
||
Wait a sec, LiveConnect does work? I was told it doesn't. Does it work/will it
work for 4.x plugins if we hook up the Java functions for LiveConnect in
ns4xPlugin?
I think plugin vendors would be VERY happy if we could provide backwards support
for LiveConnect.
Comment 62•24 years ago
|
||
Oops, sorry about that. I don't know if LiveConnect works for plugins. I know
it partially works for Java applets calling JavaScript and vice versa, but I
don't know about how plugins fit into the scheme.
Do you have a test we could try?
Comment 63•24 years ago
|
||
I don't know how to evaluate Peter's changes to see if they're good or not. The
change sounds like a hack, but it looks like it works! Who am I to block this fix?
I am *not* Brendan Eich, or Patrick Beard, or Ed Burns. So, I'm copying them to
see if they can make a ruling.
Also, does anybody know here why LiveConnect doesn't work in plugins? Could use
some explanation/help/history here, or elsewhere if this bug is not appropriate.
Comment 64•24 years ago
|
||
@@ -3319,9 +3329,12 @@
{
// do not do anything if it is already done
// use nsPluginHostImpl::ReloadPlugins to enforce loading
- if(mPluginsLoaded)
+ if(mPluginsLoaded && mLoadJava)
+ return ReloadPlugins(PR_FALSE);
+ else if (mPluginsLoaded)
return NS_OK;
could be:
if(mPluginsLoaded)
- return ;
+ return (mLoadJava)?ReloadPlugins(PR_FALSE):NS_OK;
indentation of patch looks inconsistent, and possibly tab ridden,
esp near
+void nsPluginHostImpl::EnableJava(PRBool aLoadJava)
+{
+ if (mJavaCalledBefore)
+ mLoadJava = aLoadJava;
+ else
+ mJavaCalledBefore = PR_TRUE;
}
why reset mJavaCalledBefore ??
Assignee | ||
Comment 65•24 years ago
|
||
If we don't load Java/OJI at startup, won't LiveConnect fail to initialize?
Before we check in lazy initialization, I'd like to verify that the code in DOM
that initializes LiveConnect still works.
Updated•24 years ago
|
Comment 66•24 years ago
|
||
Joe, any word on this? Can someone answer beard's question?
Comment 67•24 years ago
|
||
I am trying to figure out Jeff Dyer's suggestion, in compairesion with the
patches provided here.
I think we all agree with Patick here that the fix should not break liveConnect.
Comment 68•24 years ago
|
||
Andrew or Peter can you guys also help take a look at this?
Comment 69•24 years ago
|
||
I'll take a look at it tonight.
Assignee | ||
Comment 70•24 years ago
|
||
I agree that we can probably defer the call in nsJSEnvironment::nsJSEnvironment()
that eagerly calls nsILiveConnectManager::StartupLiveConnect(), but as soon as
the first nsJSContext object gets created, its
nsJSContext::InitializeLiveConnectClasses() method will get called, and so we'll
have to do it there, which is still too eager. The solution to this problem is to
initialize the nsJSContext's global object with the LiveConnect root properties,
"Packages", "java", and "netscape", such that the first time they are evaluated,
THEN the call to nsILiveConnectManager::StartupLiveConnect(), and
nsILiveConnectManager::InitLiveConnectClasses() occurs. What I'm not clear on, is
how to do this handoff cleanly, such that after this has happened, the values for
these properties change to their proper values.
jband and brendan can provide more technical details.
Comment 71•24 years ago
|
||
jst, what's the best way to define properties lazily? There are the
aLazyPropSpec params to nsJSUtils::nsGlobalResolve and nsGlobalEnumerate, which
come from 'replaceable' DOM IDL attributes, but DOM IDL is going away. There is
the nsIScriptNameSpaceManager/nsIScriptNameSetRegistry jazz, but I believe that
too is changing on the DOM-over-XPConnect branch. Pls. advise,
/be
Comment 72•24 years ago
|
||
I've been trying different test cases with some code changes, and found out the
following:
The main problem seems to be to delay starting LiveConnect (if it is done
correctly, lazy starting JVM seems requiring no code change). An ideal place to
start LiveConnect would be when a page is found to have JavaScript data types.
But in my tracing, I've not found the code parsing JavaScript data types
(Packages, java, etc.) in a page. Instead, I did see the code that initializing
all the JavaScript data types for any page. If that is true (currently the
browser does not parse to see if a page contains JavaScript), then I guess we
may need to add code to do the parsing, and if a page is found to have
JavaScript, start LiveConnect (along with starting JVM, as the current code
does).
Am I missing something here?
Comment 73•24 years ago
|
||
Can we adapt the ResolveStandardClasses stuff for LiveConnect? That'd let us
pull in JavaPackage and the like when they're first used.
Parsing the script and looking for references to Package and whatnot is a
non-starter, really, since it requires evaluation of the script.
Should I look at doing JSJ_ResolveLiveConnectClasses? joe.chou, can you post
your patches that get the non-LiveConnect issues resolved?
Comment 74•24 years ago
|
||
shaver is referring to the JS API's JS_ResolveStandardClass, which tries to bind
a standard name to its property value (Object, Date, RegExp, etc.) and returns a
flag telling whether it did bind. JSJ_ResolveStandardPackage is a better name
for the liveconnect function, as "Packages", "sun", "netscape", and "java" are
package, not class, names.
The call would come from GlobalWindowImpl::Resolve, in
dom/src/base/nsGlobalWindow.cpp.
/be
Comment 75•24 years ago
|
||
I'm posting this message on behalf of Joe to say that he has been away since
Monday, and is expected to be back tomorrow. That's why there's no progress on
this bug since Brendan's last comment.
Comment 76•24 years ago
|
||
What Mike is proposing seems to be the thing missing. If that can be done to
only start LiveConnect when one of the packages is first used, that would be a
good solution to this problem. I believe that Mike's suggestion also fits what
Patrick was refering to in his earlier comments. If that is true, then Mike
would you please come up with the fix to do the lazy start of LiveConnect?
With the late start of LiveConnect in place, lazy start of JVM is also done
without any other code changes. Therefore, there is no need for other patch,
unless you want to polish the code a bit. Talking about polishing the code, I do
suggest a replacement for MaybeStartupLiveConnect():
PRBool
nsJVMManager::MaybeStartupLiveConnect(void)
{
// If LiveConnect already started, do nothing.
if (fJSJavaVM) {
return PR_TRUE;
}
if (!IsLiveConnectEnabled()) {
return PR_FALSE;
}
JVM_InitLCGlue();
fJSJavaVM = JSJ_ConnectToJavaVM(NULL, NULL);
if (fJSJavaVM != NULL) {
return PR_TRUE;
} else {
// Log error?
return PR_FALSE;
}
}
There is no need to call StartupJVM in MaybeStartupLiveConnect(), since
JSJ_ConnectToJavaVM() eventually calls StartupJVM() if JVM has not been started.
The do_while is no longer needed, and it only loop once anyway (while (0)).
On the other hand, the current MaybeStartupLiveConnect() still works without any
changes.
The only changes needed seems to be the following two
1) Add the code that Mike is proposing, (JSJ_ResolveStandardPackage?), which
calls MaybeStartupLiveConnect() when a package is first used.
2) Remove the line of code calling StartupLiveConnect(), which calls
MaybeStartupLiveConnect() in the initialization of the browser, in
nsJSEnvironment::nsJSEnvironment().
Assignee | ||
Comment 77•24 years ago
|
||
One additional point to consider: if an applet decides to use the JSObject API,
but its page has no LiveConnect global references, we need to make sure that this
also initializes LiveConnect. Perhaps when nsObjectFrame loads an applet, if its
MAYSCRIPT attribute is defined, we also initialize LiveConnect.
Comment 78•24 years ago
|
||
Just to be on the safe side, Patrick, when you implement the delay startup of
LiveConnect, please also consider the case of JavaScript-to-Java communitcation
(e.g., document.Myapplet.doSomething() should still work), MAYSCRIPT should have
covered JAVA-to-JavaScript part.
Assignee | ||
Comment 79•24 years ago
|
||
The problem with the whole JSJ_ResolveStandardPackage() approach, is that Caps
defeats the whole intent in |nsSecurityNameSet::InitializeClasses()|, because it
causes "netscape.security" to be resolved. My original idea, eagerly populating
the global namespace with package objects for java, netscape, sun, and Packages,
plus a set of sub-packages, such as netscape.security, seems to be the only
practical solution to this problem. This requires splitting up LiveConnect's
initialization into 2 phases, essentially predefining all of the interesting
packages first, and then if properties are read from any of those predefined
package, firing up Java at that point using the OJI module callbacks.
Assignee | ||
Comment 80•24 years ago
|
||
Here's an initial cut at an attempt to perform 2 phase initialization. Basically,
I've delayed the full initialization of JSJavaVM objects until the first call to
JSJ_AttachCurrentThreadToJava(). I haven't checked to see if this is completely
bullet proof, but it does successfully defer the loading of the MRJ plugin until
LiveConnect is actually running.
Assignee | ||
Comment 81•24 years ago
|
||
Assignee | ||
Comment 82•24 years ago
|
||
Comment 84•24 years ago
|
||
I was planning to switch those netscape.security calls in caps over from
ScriptExternalNameSet declaration to being XPConnected objects; will this make
things easier? If so, I'll make that a priority.
Assignee | ||
Comment 85•24 years ago
|
||
No, as long as you are writing ANY sort of object in to "netscape.security" there
will be an impact on LiveConnect. Luckily, I've worked out a way to lazily
initialize LiveConnect that should work regardless.
I am seeking commentary on this patch.
Status: NEW → ASSIGNED
Assignee | ||
Comment 86•24 years ago
|
||
I have verified that it works on Linux; Java doesn't start until I load an Applet
or evaluate javascript:java.lang.System. The Linux plugin does have a tendency to
hang the browser however...
Comment 87•24 years ago
|
||
verified on win32, the patch builds, there's no java icon in the taskbar after
we start up. When I go to a page with an applet, the icon appears and java's
running.
go team!!
Comment 88•24 years ago
|
||
I tried the patch on Solaris (the patch should have included the removing of the
line of calling StartupLiveConnect() in nsJSEnvironment::nsJSEnvironment()), and
it seemed to work ok with the cases with Applet tags. But for a case without an
applet tag (see attachment below), it seemed not invoking call to Java. For
example, I set a breakpoint at getContext in ProxyJNI.cpp. Without the patch
(LiveConnect and JVM started at init), the breakpoint was hit, which then invoke
the call method to Java plugin and JVM. With the patch, the breakpoint somehow
was not hit, and no call method invoked. Is my test case valid? I might have
missed something there.
Attachment of the test case (simplified test case from 60018):
Another test HTML (with a button):
<html>
<head> <title>Live Connect using a JavaObject</title> </head>
<body>
<form ID="form1" name=myForm>
<input ID="field1" Type=text value="Live Connect using a JavaObject"
name="fieldOne">
<input ID="button1" Type=button value="Call load()" name="buttonOne"
onClick=click_doit()>
<input ID="field2" Type=text value="Live Connect using a JavaObject"
name="fieldTwo">
<input ID="button2" Type=button value="Call showAlert()"
name="buttonTwo" onClick=showAlert("showAlert()")>
</form>
<script>
function click_doit()
{
java.lang.System.out.println("*** calling new Cherokee() ");
var htmlForm = new Packages.Cherokee("Hello");
java.lang.System.out.println("*** skip calling load() ");
<!-- htmlForm.load(params); -->
java.lang.System.out.println("*** calling load() done");
}
function showAlert(txt)
{
alert ("JavaScript 'showAlert': called from " + txt);
}
var params =
{
domwin: window,
domdoc: document,
serverhost: "javaweb.eng.sun.com"
};
java.lang.System.out.println("Starting jotest.html");
</script>
</body>
</html>
Java code:
import netscape.javascript.*;
public class Cherokee
{
JSObject win = null;
//-----------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------
public Cherokee(String txt)
{
System.out.println("*** Cherokee constructor: ***" + txt);
}
//--------------------------------------------------------------------
// Public Methods
//--------------------------------------------------------------------
public void load(JSObject params)
{
JSObject jso;
System.out.println("*** cherokee.load: Start of method ***");
if (params == null) {
System.out.println("params is null");
} else {
System.out.println("calling params.getMember()");
win = (JSObject) params.getMember("domwin");
if (win == null) {
System.out.println("*** cherokee.load: win is null ***"
);
} else {
System.out.println("*** cherokee.load: win is not null
***");
}
}
System.out.println("*** cherokee.load: End of method ***");
}
}
Assignee | ||
Comment 89•24 years ago
|
||
Sorry Joe, the patch is complete. There's no need to stop calling
StartupLiveConnect() in nsJSEnvironment::nsJSEnvironment(), because Java
initializes only when LiveConnect actually tries to resolve a package into a
class. Please try running with only the last patch in your tree. I ran with just
that on Linux and things work for me.
Comment 90•24 years ago
|
||
Patrick, you are right about no need to remove StartupLiveConnect. I tried it,
and that seemed working fine.
But the problem of my test case above was still there: with the patch, clicking
the "Call load()" button did not call the load method, unless bringing up the
Java console first, which loaded Java plugins. Without the patch, clicking the
button invoked the call method. Is that a problem? Did you tested it with a case
that did not have an applet tag, something similar to the Oracle case in 60018?
Assignee | ||
Comment 91•24 years ago
|
||
I tested with the URL "javascript:java.lang.System" which fires up Java. Does
this simple URL work for you? I will try your test case, which may be failing for
other reasons. Would you please provide a review for this patch?
Comment 92•24 years ago
|
||
Patrick, can you please attach another diff? I can't get this one to apply:
D:\Projects\trunk\mozilla\js\src\liveconnect>patch -i 26516.diff jsj.c
patch -i 26516.diff jsj.c
patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input.
Comment 93•24 years ago
|
||
I tried the url on my SOlaris, and I saw similar problem: if I tried to launch
the url without Java plugin loaded first, nothing showed up; but if I opened the
Java console first and then launch the url, I saw "[JavaClass java.lang.System]"
printed on the page. I am going to tried on another trunk build on Solaris and
Linux, and see how it goes.
Comment 94•24 years ago
|
||
To edburns: Patch http://bugzilla.mozilla.org/showattachment.cgi?attach_id=30892
has a weired format. Solution for unix users:
-- snip --
% cat xxx.diff | tr "[\r]" "[\n]" >yyy.diff
gisburn@castor/home/gisburn/tmp/moz% gpatch -p0 --dry-run <yyy.diff
patching file jsj.c
Hunk #1 FAILED at 449.
Hunk #2 succeeded at 468 with fuzz 2.
Hunk #3 succeeded at 948 (offset 253 lines).
1 out of 3 hunks FAILED -- saving rejects to file jsj.c.rej
-- snip --
Comment 95•24 years ago
|
||
I've tried this on an 11pm last night Win32 trunk clobber build and I find that
the plugins module is loaded at startup. However, this is the plugin code. Is
your diff supposed to prevent all java related initilization, or only
liveconnect related initialization?
nsPluginHostImpl ctor
plugins at: D:\Projects\trunk\mozilla\dist\WIN32_D.OBJ\bin\plugins
plugins at: C:\Program Files\Opera\Program\Plugins
For application/x-java-vm found plugin
D:\Projects\trunk\mozilla\dist\WIN32_D.OBJ\bin\plugins\NPOJI600.dll
Comment 96•24 years ago
|
||
Debugging further, I find that on win32, the nsJVMManager::StartupJVM() gets
called even with your patch applied.
Here's the stack trace:
nsJVMManager::StartupJVM() line 573
nsJVMManager::MaybeStartupLiveConnect() line 780 + 20 bytes
nsJVMManager::StartupLiveConnect(nsJVMManager * const 0x0199fa58, JSRuntime *
0x010579c8, int & 0) line 128 + 11 bytes
nsJSEnvironment::nsJSEnvironment() line 1505 + 49 bytes
nsJSEnvironment::GetScriptingEnvironment() line 1446 + 27 bytes
NS_CreateScriptContext(nsIScriptGlobalObject * 0x0197ec90, nsIScriptContext * *
0x01979240) line 1545 + 5 bytes
nsDocShell::EnsureScriptEnvironment(nsDocShell * const 0x01979190) line 4439 +
50 bytes
nsWebShell::GetInterface(nsWebShell * const 0x019791b4, const nsID & {...},
void * * 0x0012fbd4) line 329 + 19 bytes
nsGetInterface::operator()(const nsID & {...}, void * * 0x0012fbd4) line 37 +
31 bytes
nsCOMPtr<nsIDOMWindowInternal>::assign_from_helper(const nsCOMPtr_helper &
{...}, const nsID & {...}) line 970 + 18 bytes
nsCOMPtr<nsIDOMWindowInternal>::nsCOMPtr<nsIDOMWindowInternal>(const
nsCOMPtr_helper & {...}) line 552
nsAppShellService::GetHiddenWindowAndJSContext(nsAppShellService * const
0x00aeb350, nsIDOMWindowInternal * * 0x0012fc7c, JSContext * * 0x0012fc80) line
713 + 32 bytes
nsAppShellService::SetXPConnectSafeContext() line 177 + 40 bytes
nsAppShellService::CreateHiddenWindow(nsAppShellService * const 0x00aeb350)
line 248
main1(int 2, char * * 0x00a359b0, nsISupports * 0x00000000) line 988
main(int 2, char * * 0x00a359b0) line 1300 + 37 bytes
mainCRTStartup() line 338 + 17 bytes
KERNEL32! 77f1ba3c()
Comment 97•24 years ago
|
||
I tried on the load from the tip of the trunk on Solaris (built last night) and
Linux (built today), found similar result:
The Java JVM was started at startup (StartupJVM got called), and all the MIME
types got registered.
On the other hand, my previous testing was done on an OEM load on Solaris. In
that case, with the patch, Java JVM was NOT started at startup time, and the
url, "javascript:java.lang.System", would not work unless I opened Java console
(which started JVM and loaded plugins' MIME types) first.
Assignee | ||
Comment 98•24 years ago
|
||
I concur, nsJVMManager::StartupJVM() does get called still, but, if I set a
breakpoint on the MRJ plugin's MRJPlugin::StartupJVM() method, it doesn't get
called until I actually do something with Java, such as a javascript: URL that
references java.lang.System. Does the Sun Java plugin startup Java
unconditionally or does it wait until its nsIJVMPlugin::StartupJVM() method is
called?
Comment 99•24 years ago
|
||
Patrick, that patch looks ok to me, barring calls to these functions that happen
even if the JavaVM has not been created/attached:
JSJ_DisconnectFromJavaVM
JSJ_AttachCurrentThreadToJava
JSJ_DetachCurrentThreadFromJava
Should these have null defenses against java_vm anyway?
r/sr=brendan@mozilla.org modulo that.
/be
Assignee | ||
Comment 100•24 years ago
|
||
Assignee | ||
Comment 101•24 years ago
|
||
Comment 102•24 years ago
|
||
Yeap, java_vm on Solaris would not be started till the first LiveConnect call.
The patch seemed doing what it suppose to do.
Comment 103•24 years ago
|
||
ra=edburns.
Assignee | ||
Comment 104•24 years ago
|
||
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 105•24 years ago
|
||
Is it possible that this fix causes a crash when going to pages with applets
when the plugin is not installed and when "Java Enabled" is checked in the
preferences? Should I file a new bug about this?
Seen by two people on linux, CVS build from one hour ago (04/19)
Comment 106•24 years ago
|
||
When I tested the patch, I saw the crash with or without the patch. I don't
think the crash is related to the patch. There is a bug about the crash leaving
an applet page, and the bug number is 75070.
Comment 107•24 years ago
|
||
*** Bug 78220 has been marked as a duplicate of this bug. ***
Comment 108•24 years ago
|
||
verified that nsJVMManager::StartupJVM() does not get called on startup anymore
on trunk builds.
Status: RESOLVED → VERIFIED
Comment 109•23 years ago
|
||
wooohooo ? anyone still working on this ? atleast update the target milestone
Comment 110•23 years ago
|
||
umm ... Michael ... this bug is already fixed
Comment 111•23 years ago
|
||
ummm, just testing if you all watch out carefully *doh* *blush*
Updated•3 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•