When will the tabId change
google-chrome, google-chrome-extension
Solution
By no means authoritative answer:
It has to do with pre-rendering, and that specific case may have to do with Instant search. As you type in the address bar, Chrome apparently pre-fetches and pre-renders some pages for faster navigation. Even if you do not trigger this via address bar, Chrome still can do tab swapping for performance reasons.
Consider the description of `chrome.tabs.onReplaced`:
Fired when a tab is replaced with another tab due to prerendering or instant.
Or, this remark in `chrome.webNavigation` API docs:
Not all navigating tabs correspond to actual tabs in Chrome's UI, e.g., a tab that is being pre-rendered. Such tabs are not accessible via the tabs API nor can you request information about them via `webNavigation.getFrame` or `webNavigation.getAllFrames`. Once such a tab is swapped in, an onTabReplaced event is fired and they become accessible via these APIs.
To summarize:
For performance reasons Chrome can spawn a separate, invisible tab, and swap an existing tab with this pre-rendered tab.
If that happens, a `chrome.tabs.onReplaced` event is dispatched, providing old and new `tabId`s.
Problem
I am working on a Chrome Extension capturing all of the web data. I just found that the change to address bar can lead to a tabId change. Anyone has a full idea about when there is a change to the tabId?