8

Hello I am developing a HTML 5 game and in Chrome the animations looks great but in firefox not! I was searching over the internet and i found a solution that i need to change some settings in about:config and they are:

webgl.force-enabled=true
webgl.msaa-force=true
layers.acceleration.force-enabled=true
gfx.direct2d.force-enabled=true
stagefright.force-enabled=true

I change those setting manually and the animations looks great in Firefox. Now my question is how can I do that using javascript? Is it possible?

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
liquid boy
  • 145
  • 1
  • 6
  • 10
    Hopefully not ! – John Dvorak Dec 17 '12 at 13:27
  • At least not from an arbitrary website. – Bergi Dec 17 '12 at 13:28
  • 3
    Nope, would'nt that be great for all the webs delinquents if they could just change the browser settings as they pleased! – adeneo Dec 17 '12 at 13:29
  • 2
    Why the down vote and vote to close? This is a legit question, written clearly with some research shown on the matter. It is a constructive question. While you may not want browsers to implement the behavior asked for, it's certainly a legit question. – tkone Dec 17 '12 at 13:34
  • @JanDvorak that's a quite unconstructive comment. As shown in the answers there ARE solutions to this issue (extensions). While you might not want someone to do it, this does NOT serve as a honest comment or response to the question at hand. – tkone Dec 17 '12 at 13:35
  • 1
    @tkone the meaning of my comment is: if there is a way for a website to modify `about:config` globally, then it's an enormous security threat. – John Dvorak Dec 17 '12 at 13:39
  • @JanDvorak But the question being asked is not about security or anything, but rather how would someone be able to modify it. There is a way (writing an extension) which would satisfy the OP's question AND your security concerns. Always assume that unless specifically stated, all solutions to the issue are open to the OP. – tkone Dec 17 '12 at 13:41
  • @tkone I also (incorrectly?) assumed that installing an extension/plugin was not an option. Note the answer doesn't (and shouldn't) work from a web page. – John Dvorak Dec 17 '12 at 13:44
  • @JanDvorak why make that assumption? There's nothing stated in the original question which would lead me to believe that the OP is not interested in anyway that this can be accomplished. Your comment could have been used to help further clarify the OPs intent as to how they were wanting to accomplish this goal. – tkone Dec 17 '12 at 13:46

2 Answers2

3

A discussion in the MozillaZine forum suggests creating a bookmarklet as follows (instructions and code copied from there):

  1. Make a file in your Firefox installation folder, under the res directory, called for example 'proxy.htm', and put this in it:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
       <title>Proxy Toggle</title>
       <script type="text/javascript">
       // <![CDATA[
       function loaded() { 
          netscape.security.PrivilegeManager
          .enablePrivilege("UniversalBrowserAccess UniversalXPConnect");
          var prefs = Components.classes["@mozilla.org/preferences-service;1"]
                      .getService(Components.interfaces.nsIPrefBranch);
          if (prefs.getIntPref("network.proxy.type") == 0) {
             prefs.setIntPref("network.proxy.type", 1);
          }
          else {
             prefs.setIntPref("network.proxy.type", 0); 
          }
          self.close();
       }; 
       self.onload = loaded;   
       // ]]>
       </script>
    </head>
    <body>
       Please wait...
    </body>
    </html>
    
  2. Then make a bookmarklet to toggle the state of the proxy pref, and put this as the location:

    javascript: void(window.open('resource:///res/proxy.htm'));
    

See: http://forums.mozillazine.org/viewtopic.php?f=7&t=87755

bfavaretto
  • 71,580
  • 16
  • 111
  • 150
Pavel Hodek
  • 14,319
  • 3
  • 32
  • 37
  • 1
    Thank you for an answer that actually attempts to help the OP out with their issue. – tkone Dec 17 '12 at 13:35
  • @tkone Unfortunately it wasn't an actual answer before my edit. Link-only answers are frequently deleted from StackOverflow, because the links can break and the answer becomes useless. We're encouraged to edit those answers to add quotes the relevant parts from the link, or flag them as not an answer. – bfavaretto Dec 17 '12 at 13:47
  • @liquidboy don't forget to accept the answer if you find it satisfactory. Note the empty checkmark beside the answer. – John Dvorak Dec 17 '12 at 13:56
  • Nifty trick but I still have to downvote it because it is a horribly bad advise in the context of this question (see my answer). – Wladimir Palant Dec 17 '12 at 14:35
  • 2
    @WladimirPalant bad advice, however answers the question. the question was not "is this a good idea" but rather "how can i do this." making a remark about it being bad advice is good. down voting (in favor of your answer) is sort of petty. answering the question is important; even giving advice is important. but down voting a legitimate answer that honestly solves the issue being asked seems a little odd. – tkone Dec 17 '12 at 15:36
  • @tkone: Welcome to Stack Overflow, the place where a good answer is supposed to point out the misconceptions that the question is based on. Giving people a footgun and playing innocent after that doesn't help anybody. – Wladimir Palant Dec 18 '12 at 06:56
  • @WladimirPalant Welcome to Stack Overflow where knowledge is apparently used as a lever to make those who don't have it feel less than those who do have it, and any attempt that can be made to ridicule someone must be attempted lest the OP start to feel, in some way shape or form, adequate. – tkone Dec 18 '12 at 14:51
1

You should not change these settings - not on your computer and especially not on computers of other people. These settings will be enabled anyway, assuming that the hardware and drivers are capable of handling them. The force-enabled settings are for testing only, switching them on is likely to cause instability (Firefox crashes, graphics driver crashes).

Most likely reason why Firefox didn't enable hardware acceleration automatically in your case are outdated drivers - you should install current drivers for your graphics card and recommend other people to do the same.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126