Memshrink progress, leaky add-ons and older SDK versions.

21 views
Skip to first unread message

Jeff Griffiths

unread,
May 8, 2012, 2:27:03 AM5/8/12
to mozilla-la...@googlegroups.com
Rocketeers!

I just published a post over on the AMO blog regarding this week's
exciting developments concerning memory leaks and the SDK:

http://blog.mozilla.org/addons/?p=4801

TL;DR: PLEASE Re-pack your add-ons with the latest SDK!

This isn't a panic, as the truly pathological case only involves running
older versions of the SDK with current Nightly builds. But you will need
to do so sometime in the next 12 weeks, and you might as well start soon
as SDK 1.6.1 fixes all sorts of other issues as well.

cheers, Jeff

Paul Morris

unread,
May 10, 2012, 3:53:22 PM5/10/12
to mozilla-la...@googlegroups.com
Good to hear about the breakthrough on the memshrink front! Will
probably wait until SDK 1.7 lands on Tuesday to repack my add-on.

BTW, is it currently possible to do l10n or simple-prefs with
builder/flight deck? It seems like when I last looked into it these
hadn't really landed there yet.

Thanks,
-Paul

Wes Kocher

unread,
May 10, 2012, 4:04:09 PM5/10/12
to mozilla-la...@googlegroups.com
In the "Properties" dialog (the one with the gear image), there's now a box where you can paste in additional json objects that get added to package.json for you, which will let you use localization and simple-prefs.

Paul Morris

unread,
May 10, 2012, 5:22:03 PM5/10/12
to mozilla-la...@googlegroups.com
Wes Kocher wrote:
In the "Properties" dialog (the one with the gear image), there's now a box where you can paste in additional json objects that get added to package.json for you, which will let you use localization and simple-prefs.
Thanks Wes, I hadn't seen that before.  I'm only somewhat familiar with json, but working from the simple-prefs documentation, it looks like I would just paste in code in the following format to get a single string preference, is that right?

    "preferences": [{
        "name": "somePreference",
        "title": "Some preference title",
        "type": "string",
        "value": "this is the default string value"
    }]
 


And if I wanted to have 3 preferences, one of each type, would this do it?


    "preferences": [{
        "name": "somePreference",
        "title": "Some preference title",
        "type": "string",
        "value": "this is the default string value"
    },
    {
        "name": "integerPreference",
        "title": "Integer preference title",
        "type": "integer",
        "value": 10
    },
    {
        "name": "booleanPreference",
        "title": "Boolean preference title",
        "type": "boolean",
        "value": false
    }
]


The accepted values for "type" are not listed on the simple-prefs documentation page.  I'm assuming they are "string" "integer" and "boolean".  At first I was tempted to put quotes around my boolean and integer values ("false" and "10"), but then reminded myself that json is just js, and that would make them strings.  It might be worth having one of each type in the example code on that page, for folks (ok, noobs...) like me who aren't so familiar with json.
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/addon-kit/simple-prefs.html


Localization looks a little trickier since the documentation talks about creating separate locale files and then the "SDK tools compile the locale files into a JSON format when producing an XPI."
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/l10n.html

I looked here but didn't see anything on localization:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/package-spec.html

So I'm not sure what the resulting json localization code would need to look like, in order for it to go directly into the package.json file via builder.  Or should I be working with localization files rather than json on this?

I can always wait on localization if I'm getting ahead of things here.

Thanks again,
-Paul



Will Bamberg

unread,
May 10, 2012, 6:15:27 PM5/10/12
to mozilla-la...@googlegroups.com
Hey Paul


On 12-05-10 2:22 PM, Paul Morris wrote:

The accepted values for "type" are not listed on the simple-prefs documentation page.  I'm assuming they are "string" "integer" and "boolean".  At first I was tempted to put quotes around my boolean and integer values ("false" and "10"), but then reminded myself that json is just js, and that would make them strings.  It might be worth having one of each type in the example code on that page, for folks (ok, noobs...) like me who aren't so familiar with json.
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/addon-kit/simple-prefs.html

Yes, it would! There's a bug about this. Although it hasn't landed yet,  you can see the types that are currently supported in the associated pull request.

Will

Paul Morris

unread,
May 10, 2012, 10:24:02 PM5/10/12
to mozilla-la...@googlegroups.com
Thanks Will, this looks good!  I was glad to see that there is also an option for a button which is something I'd like to use.  I got it to show up like so:

    {
        "name": "deleteData",
        "title": "Delete all data (this cannot be undone).",
        "type": "control",
        "label": "Delete All Data"
    }


(I didn't include the "value" part since no value is stored.)

But I don't know how pick up when the user clicks it.  The listener function documented here doesn't pick it up:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/addon-kit/simple-prefs.html

And I tried adding "oncommand" : "console.log('buttonclick');" but that didn't work either.  I thought this might work based on:
https://developer.mozilla.org/en/Extensions/Inline_Options

Am I missing something, or is this still in the works?   This was all on SDK 1.6.1

Cheers,
-Paul


Will Bamberg

unread,
May 16, 2012, 9:47:44 AM5/16/12
to mozilla-la...@googlegroups.com
I mistakenly sent you a link to the commit, not the pull request itself. But in the actual pull request: https://github.com/mozilla/addon-sdk/pull/405 there's an answer to this (you listen to "click" using the simple-prefs "on()" function).

Will


Paul Morris

unread,
May 16, 2012, 3:16:26 PM5/16/12
to mozilla-la...@googlegroups.com
Will Bamberg wrote:
> I mistakenly sent you a link to the commit, not the pull request
> itself. But in the actual pull request:
> https://github.com/mozilla/addon-sdk/pull/405 there's an answer to
> this (you listen to "click" using the simple-prefs "on()" function).
>
> Will

Thanks Will, this is working for me now.

-Paul
Reply all
Reply to author
Forward
0 new messages