New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 10 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Dec 2012
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug

Blocked on:
issue 163246



Sign in to add a comment

chrome.tabs.oncreated.addlistener is called twice for event pages

Reported by phanisud...@gmail.com, Nov 25 2012 Back to list

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.19 (KHTML, like Gecko) Chrome/25.0.1323.1 Safari/537.19

Steps to reproduce the problem:
Copy the attachments and run the extension, event is fired twice

What is the expected behavior?
chrome.tabs.oncreated.addlistener should be called once in an event page

What went wrong?
chrome.tabs.oncreated.addlistener is called twice in an event page

WebStore page: 

Did this work before? N/A 

Chrome version: 25.0.1323.1  Channel: dev
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
 
background.js
93 bytes View Download
manifest.json
291 bytes View Download

Comment 1 by kalman@chromium.org, Nov 27 2012

Cc: mpcomplete@chromium.org
Status: Available
This looks like a bug with event pages. If I remove the "persistent:false" from the manifest then the event only gets fired once.

It also seems specific to chrome.tabs.onCreated - I tried also setting a value in chrome.storage and observing chrome.storage.onChanged and it only gets the event twice.

Matt, any ideas?
Owner: mpcomplete@chromium.org
Status: Assigned
Summary: chrome.tabs.oncreated.addlistener is called twice for event pages (was: NULL)
This happens for chrome.tabs.onCreated and onUpdated, because they each do a custom dispatch to all listeners. "All listeners" includes lazy listeners and process listeners, so if the process is alive, it'll dispatch twice.

The quick fix is to uniq the listener list by extension_id. I'm going to think about a better solution, though. EventRouter's API sucks mustard.
Blockedon: chromium:163246
Fixing  issue 163246  would fix this the right way.
Project Member

Comment 4 by bugdroid1@chromium.org, Dec 5 2012

The following revision refers to this bug:
    http://src.chromium.org/viewvc/chrome?view=rev&revision=171141

------------------------------------------------------------------------
r171141 | mpcomplete@chromium.org | 2012-12-05T03:22:48.238191Z

Changed paths:
   M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/extensions/event_listener_map.cc?r1=171141&r2=171140&pathrev=171141
   M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/extensions/event_router.h?r1=171141&r2=171140&pathrev=171141
   M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/extensions/browser_event_router.cc?r1=171141&r2=171140&pathrev=171141
   M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/extensions/window_event_router.cc?r1=171141&r2=171140&pathrev=171141
   M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/extensions/event_router.cc?r1=171141&r2=171140&pathrev=171141
   M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/extensions/event_listener_map_unittest.cc?r1=171141&r2=171140&pathrev=171141

Add a more generic API for dispatching events from extension EventRouter.

Also fixes a bug where chrome.tabs.oncreated.addlistener is called twice for
event pages.

The new API allows the caller to specify a callback which gives them a chance
to tailor the event args for each extension and Profile.

BUG= 163246 , 162543 


Review URL: https://chromiumcodereview.appspot.com/11316338
------------------------------------------------------------------------
Status: Fixed
Project Member

Comment 6 by bugdroid1@chromium.org, Mar 11 2013

Labels: -Feature-Extensions Cr-Platform-Extensions
As of 28.0.1500.71 on OS X, this appears to be happening again with chrome.tabs.onUpdated. Possible regression?
28.0.1500.71 
OS X 10.7.5

Comment 9 by kgra...@gmail.com, Aug 17 2013

I'm seeing this, too.
Google Chrome	28.0.1500.95 (Official Build 213514) 
Platform	4100.89.0 (Official Build) stable-channel link

Extra info: I don't have "tabs" permission for my extension.

chrome.tabs.onUpdated calls callback with:
tabId, changeInfo, tab

1. 604, "loading", {...,status:"loading,...}
2. 604, "complete", {...,status:"complete",...}
3. 604, undefined, {...,status:"complete",...}

So perhaps this is not a bug, the "duplicate" events 2 and 3 are slightly different in that the second argument is not present in the third event. In any case, it is a little confusing. Perhaps this is expected behavior and I am not reading the docs correctly.

Sign in to add a comment