Mouse Lock Implementation FAQ

From CDOT Wiki
Jump to: navigation, search

Introduction

This page is a catch-all for questions about the work to implement Mouse Lock. Ask or answer any questions below using the style already started. Questions relating to anything around this work are acceptable (development issues, build problems, source code questions, spec issues, etc.). Don't be afraid, just ask! Don't judge others, just answer!

Questions

Why are we using github instead of Mozilla's Mercurial repo?

So that we don't have to learn yet another version control system. We've already learned git and github, why switch now? Mozilla's Mercurial repo is mirrored on github, and our repo is a fork of this. The main github repo (e.g., https://github.com/doublec/mozilla-central) gets updated regularly, so you can pull from it to keep your fork in sync.

How do I build Firefox?

See https://developer.mozilla.org/En/Developer_Guide/Build_Instructions

What's the difference between a DEBUG and RELEASE build?

With a DEBUG build you can attach a debugger or use various logging and instrumentation in order to see how your source code works. A RELEASE build removes this, and optimizes your code.

How do I create a DEBUG build?

You need to add info to your .mozconfig file, see https://developer.mozilla.org/en/Configuring_Build_Options

ac_add_options --disable-optimize
ac_add_options --enable-debug

How do I get my build to go faster?

Use Linux if you can (faster I/O), use more RAM if you can. Make sure you enable parallel make jobs so you can take advantage of your CPU cores. In your .mozconfig, add a j value that is 2*cores+1 or at least 2:

mk_add_options MOZ_MAKE_FLAGS=-j5

How do I resolve the windows line ending error when trying to build FireFox?

For more information, this is the error I get.

client.mk:121: *** This source tree appears to have Windows-style line endings.
To convert it to Unix-style line endings, run "python mozilla/build/win32/mozilla-dos2unix.py".
Stop.

The python code will not work because it's trying to look for a CVS directory that does not exist in the mozilla-central folder.

Bug Ticket: https://bugzilla.mozilla.org/show_bug.cgi?id=699203

Answer 1: We should file a bug on this and get the script + error message fixed. Ask on irc for tips on how to do this, or we can do on Tuesday.

Answer 2: This happens because the default setting for msys git on Windows is to checkout files with CRLF line endings. To fix this, you need to reinstall msys git and when you get to Configure the line ending conversions, choose option 2 Checkout as-is, commit Unix-style line endings here http://help.github.com/images/bootcamp/bootcamp_1_win_install_7.jpg. Once you've reinstalled msys git, you need to checkout the repository with the correct LF line endings with the following commands:

git ls-files -z | xargs -0 rm;
git checkout .

Answer 3: Before cloning the repository, set core.autocrlf to input (which always checks things out with LF line endings) by using the following line.

git config --global core.autocrlf input

Afterwards, you can freely clone the repository and the build should now work.

How do I resolve the error where CL cannot be found?

This is the error that comes up:

checking whether the C compiler (cl ) works... no configure: error: installation or configuration problem: C compiler cannot create executables. Fix above errors and then restart with "make -f client.mk build" make[1]: *** [configure] Error 1 make[1]: Leaving directory `/d/proj/mozilla' make: *** [/d/proj/mozilla/obj-i686-pc-mingw32/Makefile] Error 2

Answer 1:

This error is due to the .bat file not being able to find the vcvars32 or 64 file. This is because when we run the wrong .bat file. When the file says -x64 after it, for example 'start-msvc9-x64' it is not necessarily saying this needs to be run in a 64 bit operating system but instead if you look inside the bat file you will see that this pretty much just means that it will be looking for the vcvars file in %VC9EXPRESSDIR%\bin\amd64\vcvars64.bat instead of Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat so make sure you are running the correct batch file and if you get this error check the path in the file to make sure it goes to the right place.

How do I resolve the atlbase.h being missing?

While running the make command, you get an error saying that atlbase.h file is missing!

Answer 1:

Apparently this is a very much known issue because apparently VS 2008 express does not come with this file, while the Professional version does come with it. Mozilla gives the workaround of downloading the last version of of microsoft SDK which came with this file which is 2003. https://developer.mozilla.org/en/atlbase.h. After you install it close and open the bat file again and rerun the make file.

After building a debug version of Firefox on Windows, should I be seeing a lot of WARNING messages?

After a successful build, I launched Firefox Nightly, I got a command prompt screen that started outputting messages. Many of them are warning messages, should I be worried? Also, certain warnings (assertions) causes pop ups that need to be dealt with, is there a way to get rid of that?

Answer 1: No, the warning messages are normal. If you're using command prompt to start firefox.exe, you can type:

set XPCOM_DEBUG_BREAK=warn

NOTE: in a BASH shell you usually have to do it this way:

export XPCOM_DEBUG_BREAK=warn

That should suppress all pop ups. This is only necessary for windows. Mac and Linux machines should be set to this by default.

Can't find header GL/glx.h for WebGL

While running make, the following error presents itself:

configure: error: Can't find header GL/glx.h for WebGL (install mesa-common-dev (Ubuntu), mesa-libGL-devel (Fedora), or Mesa-devel (openSUSE)))

Answer 1: This error is most likely caused by an error in your .mozconfig file. Make sure that all commands are prefixed properly with their correct add command (mk_add... or ac_add...)

LNK 1210 Error

While running make, the following error presents itself:

LINK : fatal error LNK1210: exceeded internal ILK size limit; link with /INCREMENTAL:NO

Answer 1: This error is most likely caused by VC's incremental linking reaching its hard coded limit. To fix the problem, edit your config.in

and locate the line #2505 find the following section of code, and insert -INCREMENTAL:NO options into LDFLAGS flag.
if test $_MSC_VER -ge 1400; then
  LDFLAGS=”$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT -INCREMENTAL:NO“
  dnl For profile-guided optimization
  PROFILE_GEN_CFLAGS=”-GL”
  PROFILE_GEN_LDFLAGS=”-LTCG:PGINSTRUMENT”

How to pull new changes for mouselock

1. Copy the repo URL in git hub
2. git remote add <repo name> git://<url>
3. git checkout master, pull to master first to avoid conflict
4. git pull <repo name>/master
5. git checkout mouselock, change to mouse lock to merge with our up to date master.
6. git merge master

To fix a merge conflict
1. git status, to see what files have an issue
2. git add <file>, fix then add those files
3. git commit

Fixing rename errors in github

One problem that users can run into when trying to merge large number of files in github is the inability of renaming those files. The merge command on github have a limit to how much files can be renamed (not sure the exact limit, but I believe it is O^n limit). To increase the limit for large merge, users can re-set the upper limit with the help of the following command:

git config merge.renameLimit 999999

If you wish to re-set to the default limit afterwards, then do this:

git config --unset merge.renameLimit

How do I get a Document (nsIDocument) from a Window (nsIDOMWindow)?

Answer: Given aWindow, an nsIDOMWindow*

nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aWindow);
nsCOMPtr<nsIDocument> doc;
if (win) {
  doc = do_QueryInterface(win->GetExtantDocument());
}
// doc is now an nsIDocument

How do I get from a Window (nsIDOMWindow) to a Widget (nsIWidget, nsBaseWidget, nsWindow, etc)?

Answer: Given aWindow, see http://dxr.mozilla.org/mozilla/mozilla-central/toolkit/xre/nsNativeAppSupportUnix.cpp.html#l201

  nsCOMPtr<nsPIDOMWindow> domWindow(do_QueryInterface(aWindow));
  if (!domWindow)
    return NULL;

  nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(domWindow->GetDocShell());
  if (!baseWindow)
    return NULL;

  nsCOMPtr<nsIWidget> widget;
  baseWindow->GetMainWidget(getter_AddRefs(widget));
  // widget is now your widget

How can I stack trace events in Firefox in Windows using Visual Studio?

Answer 1: The answer is going to assume you know the basics of debugging on Visual Studio, like how to start debugging, step into, step out, step over, etc. If you haven't already follow the instructions on this site. You don't have to do the optional part. Make sure you build your debug version of Firefox before this. Once you've completed the tasks, find out where you want to put your break point, (use mxr or dxr), and then hit debug. When you rebuild Firefox, you won't need to do the steps all over again, your solution explorer will automatically update itself.

See also https://cs.senecac.on.ca/~david.humphrey/writing/debugging-firefox.html, which is old, but likely still helpful.

How do I programatically set the mouse cursor position?

Answer: See how SynthesizeNativeMouseEvent does it on Windows:

5941 nsresult
5942 nsWindow::SynthesizeNativeMouseEvent(nsIntPoint aPoint,
5943                                      PRUint32 aNativeMessage,
5944                                      PRUint32 aModifierFlags)
5945 {
5946   RECT r;
5947   ::GetWindowRect(mWnd, &r);
5948   ::SetCursorPos(r.left + aPoint.x, r.top + aPoint.y);
5949 
5950   INPUT input;
5951   memset(&input, 0, sizeof(input));
5952 
5953   input.type = INPUT_MOUSE;
5954   input.mi.dwFlags = aNativeMessage;
5955   ::SendInput(1, &input, sizeof(INPUT));
5956 
5957   return NS_OK;
5958 }

How do I work with Preferences in Mozilla?

Answer: See https://wiki.mozilla.org/Education/Learning/Preferences


Blur a window on a mochitest

Instead of window.blur(), window.open() will blur the focused window.