I have a problem with the following code:
await browser.tabs.update(tab.id, {active: true});
const shot = await browser.tabs.captureVisibleTab(tab.windowId, {format: 'png'});
This works well on Desktop Firefox and Chrome, but on Firefox for Android this will always take a screenshot of current tab. If I place some timeout (delay) before the shooting, it will work.
Is there some hotfix for awaiting tab activation in Android?
EDIT:
Hotfix is ready :
while ((await getActiveTab()).id !== tab.id) {
console.warn('TAB IS STILL NOT ACTIVE');
await timeoutPromise(1);
}
And this is what I see in the console:
15:26:59.647 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.649 TAB IS STILL NOT ACTIVE
15:26:59.666 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.667 TAB IS STILL NOT ACTIVE
15:26:59.678 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.680 TAB IS STILL NOT ACTIVE
15:26:59.691 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.693 TAB IS STILL NOT ACTIVE
15:26:59.705 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.706 TAB IS STILL NOT ACTIVE
15:26:59.727 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.729 TAB IS STILL NOT ACTIVE
15:26:59.743 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.744 TAB IS STILL NOT ACTIVE
15:26:59.759 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.760 TAB IS STILL NOT ACTIVE
15:26:59.768 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.769 TAB IS STILL NOT ACTIVE
15:26:59.786 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.787 TAB IS STILL NOT ACTIVE
15:26:59.803 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.805 TAB IS STILL NOT ACTIVE
15:26:59.824 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.826 TAB IS STILL NOT ACTIVE
15:26:59.837 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.837 TAB IS STILL NOT ACTIVE
15:26:59.863 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.866 TAB IS STILL NOT ACTIVE
15:26:59.884 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.884 TAB IS STILL NOT ACTIVE
15:26:59.893 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.894 TAB IS STILL NOT ACTIVE
15:26:59.900 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.901 TAB IS STILL NOT ACTIVE
15:26:59.908 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.909 TAB IS STILL NOT ACTIVE
15:26:59.917 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.918 TAB IS STILL NOT ACTIVE
15:26:59.933 TAB IS STILL NOT ACTIVE screen.ts:23:18
15:26:59.945 TAB IS STILL NOT ACTIVE
As you can see, it takes almost 300ms to actually activate the tab!
EDIT 2:
Iâve filed a new bug for this.