3

I have an extension that I recently pushed an update for with updated permissions. Some users are upgrading and reporting that the app doesn't work after the update, in order to make it work again they are having to completely uninstall the app and re-install and everything works as it should.

Has anyone ever had a similar issue? For me in testing everything updated properly, and not everyone is having this issue but it is becoming an issue.

Something to note - the popup tab does work it's just the context menu that has the issue.

EDIT - I am unable to replicate and have no clear way to test this beyond getting reports from users. I did notice a drop in reports after deploying another update where I adjusted the order of the permissions... I don't see how this is at all related but I am looking for any clarity as to why this is happening and if there is something that can be done to avoid it in the future.

11
  • Have you already tried to reproduce the bug? If yes, have you also tried to create a reduced test case that shows the bug? Which version of Chrome are you using?
    – Rob W
    Nov 20, 2015 at 20:14
  • What permissions specifically were added/removed/updated?
    – wOxxOm
    Nov 20, 2015 at 20:38
  • @RobW I am unable to reproduce. it's all over the place I added both a startup and oninstall event listener and for me it creates the context menu correctly all of the time. For others it seems to not work at all. Nov 20, 2015 at 22:02
  • @wOxxOm the new permission is 'downloads' so you can download directly from the app. I have had this issue come up before for some people but this is happening on a much larger scale... since rollout over 2k people have started reporting it... Nov 20, 2015 at 22:03
  • @DrewDahlman You know best what exactly changed. Could you try to simulate what you did (both in API changes, permission changes and update submissions to the CWS).
    – Rob W
    Nov 20, 2015 at 22:12

1 Answer 1

5

You're creating context menu items in a listener for the chrome.runtime.onInstalled event. This is the documented and recommended way to create context menu items, but it is not always triggered due to bugs in Chrome (crbug.com/388231, crbug.com/389631, crbug.com/264963).

I guess that in your case the permission update caused the extension to be disabled, and then chrome.runtime.onInstalled was not triggered any more after re-enabling it because of crbug.com/388231.

A work-around for this bug is to use a short timer and try to update the context menu item that should have been created. If the onInstalled event is not triggered, then the context menu is not created and trying to update it will fail. This condition can then be used to ensure that the context menu is created correctly.

var SOME_CONTEXTMENU_ID = "GifMeContextMenu";

function onInstalled() {
    // ... do your thing, e.g. creating a context menu item:
    chrome.contextMenus.create({
        "title": "GifMe",
        "contexts": ["image"],
        "id": SOME_CONTEXTMENU_ID
    });
}

// Should be triggered whenever the extension or browser is
// reloaded, installed or updated.
chrome.runtime.onInstalled.addListener(onInstalled);

setTimeout(function() {
    // This .update() call does not change the context menu if it exists,
    // but sets chrome.runtime.lastError if the menu does not exist.
    chrome.contextMenus.update(SOME_CONTEXTMENU_ID, {}, function() {
        if (chrome.runtime.lastError) {
            // Assume that crbug.com/388231 occured, manually call the
            // onInstalled handler.
            onInstalled();
        }
    });
}, 222); // <-- Some short timeout.
0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.