Closed Bug 487174 Opened 16 years ago Closed 16 years ago

Modify nsXULStub to launch from GRE folder on WinCE

Categories

(Toolkit Graveyard :: XULRunner, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.9.2a1

People

(Reporter: mfinkle, Assigned: hiro)

References

Details

(Keywords: fixed1.9.1)

Attachments

(1 file, 2 obsolete files)

Because of LoadLibrary behavior on WinCE we can't load DLLs from outside the process folder or several other restrictive locations. Some background can be found here: https://wiki.mozilla.org/Mobile/WinCE_LoadLibrary_SearchPath_Bug_Notes We intend to try a modified version of Option #1 from the wiki page: * Launch fennec.exe from wherever it is installed (phase 1) * The stub will find the GRE folder * The stub will copy itself to the GRE folder * The stub will launch the copy using the -app parameter, which will point back to the actual install location (phase 2) * The second launch will load the XPCOM Glue and use the application.ini to launch Fennec Using this approach allows Fennec to use XPCOM Glue and icon resources loaded into fennec.exe, working around some process issues with the WinCE task manager. Yes, this is a PITA
Can you clarify some things from the wiki: * The XPCOM glue should be explicitly loading all the dependencies of xul.dll (using LoadLibrary and a full path name). Is this not sufficient? Or if we load nspr4.dll using LoadLibrary, does WinCE not use that copy when resolving implicit dependencies later?
As far as I can confirm on Windows Mobile 6 Emulator, LoadLibraryExW with 0 for dwFlags can load xulrunner DLLs and Fennec seems work well at least with release build. But unfortunately with debug build (i.e. --enable-debug option), loading xul.dll fails due to " not enough storage is available to complete this operation" error. I guess the error causes by limitation of 32MB on WinCE application because xul.dll with debug build is 30MB itself. See http://msdn.microsoft.com/en-us/library/ms836325.aspx#advmemmgmt_topic3
Attached patch A patch (obsolete) — Splinter Review
I tested with this patch.
(In reply to comment #2) > But unfortunately with debug build (i.e. --enable-debug option), loading > xul.dll fails due to " > not enough storage is available to complete this operation" error. After resetting emulator, this error has gone.
Comment on attachment 371597 [details] [diff] [review] A patch > static void > ReadDependentCB(const char *aDependentLib) > { >- >+ wchar_t wideDependentLib[MAX_PATH]; >+ MultiByteToWideChar(CP_ACP, 0, aDependentLib, -1, wideDependentLib, MAX_PATH); >+ > HINSTANCE h = >- LoadLibraryExW(NS_ConvertUTF8toUTF16(aDependentLib).get(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); >- if (!h) >+#ifdef WINCE >+ LoadLibraryExW(wideDependentLib, NULL, 0); >+#else >+ LoadLibraryExW(wideDependentLib, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); >+#endif >+ if (!h) { >+ wprintf(L"Error loading %s %s\n", wideDependentLib, lpMsgBuf); Oops, sorry. lpMsgBuf does not exist in the path.
(In reply to comment #2) > As far as I can confirm on Windows Mobile 6 Emulator, LoadLibraryExW with 0 for > dwFlags can load xulrunner DLLs and Fennec seems work well at least with > release build. Where is fennec.exe located when you launch? Is fennec.exe in the same folder as xulrunner.exe?
(In reply to comment #6) > Where is fennec.exe located when you launch? Is fennec.exe in the same folder > as xulrunner.exe? No. fennec.exe is in the parent folder of xulrunner.exe. Like this: bin\fennec.exe bin\xulrunner\xulrunner.exe bin\xulrunner\xul.dll ...
Attached patch sligth revision on patch (obsolete) — Splinter Review
Fixes compiler error from a missing lpMsgBuf in ReadDependentCB() function.
Attachment #371597 - Attachment is obsolete: true
(In reply to comment #8) > Fixes compiler error from a missing lpMsgBuf in ReadDependentCB() function. Thank you, John. The patch works fine on your environment? If so, Bug 482741 and Bug 482285 also are fixed by this patch, I think.
The latest patch works just fine on my WinMobile device - A HTC Touch Pro. I applied this patch, compiled a release build, made a install CAB, and ran the install CAB on my device after removing all other fennec binaries from both the device and the associated microSD storage card. Fennec started up just fine - so I think this latest patch works great.
(In reply to comment #1) > Can you clarify some things from the wiki: > > * The XPCOM glue should be explicitly loading all the dependencies of xul.dll > (using LoadLibrary and a full path name). Is this not sufficient? Or if we load > nspr4.dll using LoadLibrary, does WinCE not use that copy when resolving > implicit dependencies later? Benjamin - It appears to be sufficient. The patch from Hiroyuki Ikezoe, tweaked by Wolfe, appears to get XPCOMGlue/WinCE working just like other platforms. That is the intent of this bug, so that's the patch we'd like to go with. Setting r?
Attachment #371964 - Flags: review?(benjamin)
Blocks: 482741
Blocks: 482285
Comment on attachment 371964 [details] [diff] [review] sligth revision on patch >diff --git a/xpcom/glue/standalone/nsGlueLinkingWin.cpp b/xpcom/glue/standalone/nsGlueLinkingWin.cpp This patch is too big... you should be able to use symbolic constant defines: #ifdef WINCE #define MOZ_LOADLIBRARY_FLAGS 0 #else #define MOZ_LOADLIBRARY_FLAGS LOAD_WITH_ALTERED_SEARCH_PATH #endif > static void > ReadDependentCB(const char *aDependentLib) > { >- >+ wchar_t wideDependentLib[MAX_PATH]; >+ MultiByteToWideChar(CP_ACP, 0, aDependentLib, -1, wideDependentLib, MAX_PATH); >+ > HINSTANCE h = >- LoadLibraryExW(NS_ConvertUTF8toUTF16(aDependentLib).get(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); >- if (!h) >+#ifdef WINCE >+ LoadLibraryExW(wideDependentLib, NULL, 0); >+#else >+ LoadLibraryExW(wideDependentLib, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); >+#endif What was the motivation for changing from UTF8 to the native codepage here? This value originally comes from http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/standalone/nsXPCOMGlue.h#103 which doesn't have a character set notation, and is passed from nsXULStub.cpp. I think that on Windows/WINCE it should be UTF8, not native, but we should verify this.
Attachment #371964 - Flags: review?(benjamin) → review-
(In reply to comment #12) > > static void > > ReadDependentCB(const char *aDependentLib) > > { > >- > >+ wchar_t wideDependentLib[MAX_PATH]; > >+ MultiByteToWideChar(CP_ACP, 0, aDependentLib, -1, wideDependentLib, MAX_PATH); > >+ > > HINSTANCE h = > >- LoadLibraryExW(NS_ConvertUTF8toUTF16(aDependentLib).get(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); > >- if (!h) > >+#ifdef WINCE > >+ LoadLibraryExW(wideDependentLib, NULL, 0); > >+#else > >+ LoadLibraryExW(wideDependentLib, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); > >+#endif > > What was the motivation for changing from UTF8 to the native codepage here? > This value originally comes from > http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/standalone/nsXPCOMGlue.h#103 > which doesn't have a character set notation, and is passed from nsXULStub.cpp. > I think that on Windows/WINCE it should be UTF8, not native, but we should > verify this. This is a trace that I had been trying to load libraries and I am not sure the conversion is now needed since I have no machine for building here. I will confirm it is needed day after tomorrow.
Attached patch update patchSplinter Review
define MOZ_LOADLIBRARY_FLAGS.
Attachment #372339 - Flags: review?(benjamin)
(In reply to comment #12) > > static void > > ReadDependentCB(const char *aDependentLib) > > { > >- > >+ wchar_t wideDependentLib[MAX_PATH]; > >+ MultiByteToWideChar(CP_ACP, 0, aDependentLib, -1, wideDependentLib, MAX_PATH); > >+ > > HINSTANCE h = > >- LoadLibraryExW(NS_ConvertUTF8toUTF16(aDependentLib).get(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); > >- if (!h) > >+#ifdef WINCE > >+ LoadLibraryExW(wideDependentLib, NULL, 0); > >+#else > >+ LoadLibraryExW(wideDependentLib, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); > >+#endif > > What was the motivation for changing from UTF8 to the native codepage here? > This value originally comes from > http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/standalone/nsXPCOMGlue.h#103 > which doesn't have a character set notation, and is passed from nsXULStub.cpp. > I think that on Windows/WINCE it should be UTF8, not native, but we should > verify this. I forgot to an important thing that the argument source of ReadDependentCB is already converted to multi-byte code at http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/standalone/nsGlueLinkingWin.cpp#156 so we need to reconvert it to UTF-16.
Comment on attachment 372339 [details] [diff] [review] update patch Please file a followup on the CP_ACP bugs: I believe we should be using UTF8 throughout this code and should not have any "native codepage" char*s.
Attachment #372339 - Flags: review?(benjamin) → review+
(In reply to comment #16) > (From update of attachment 372339 [details] [diff] [review]) > Please file a followup on the CP_ACP bugs: I believe we should be using UTF8 > throughout this code and should not have any "native codepage" char*s. If I understand things correctly, this includes code in nsXULStub and nsGlueLinkingWin.cpp - and any other code that uses const char buffers created in nsWindowsWMain.cpp
Blocks: 485465
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
No longer blocks: 482741
No longer blocks: 482285
Attachment #371964 - Attachment is obsolete: true
Assignee: nobody → ikezoe
Keywords: checkin-needed
Target Milestone: --- → mozilla1.9.2a1
Version: unspecified → Trunk
Comment on attachment 372339 [details] [diff] [review] update patch this resolves Bug 492948 which is a blocker
Attachment #372339 - Flags: approval1.9.1?
Comment on attachment 372339 [details] [diff] [review] update patch a191=beltzner
Attachment #372339 - Flags: approval1.9.1? → approval1.9.1+
Keywords: checkin-needed
Whiteboard: [needs 191 landing]
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: