Long running task in a google chrome extension - javascript

I have some operations (basically create new folders and links), which can take several minutes. Now the problem is that in this time chrome does somehow block such that i barely can use the browser (in the "check popup-mode"), which is bad. In addition my spinner gif does not spin. ^^
Besides that the operation is aborted if I click on another tab or so (which closes the extension) in the normal mode, which is also bad.
Does anyone have some ideas to handle these cases?

You'll do the long-running tasks in a background page. To notify the background page from the popup when to start the task, you can use message passing. Since the background page is always open, it will not stop running when you navigate away from the popup.

Related

Force all execution to pause using Javascript

I am making a chrome extension that aims to pause execution of a tab if it inactive after some time in order to stop if from consuming resources.
By "Pause", I mean something like debugger, however, debugger does not seem to work unless the developer inspector tool is open.
Is there anyway to stop a tab from consuming resources until the user goes to that tab and click on something (like the play button on debugger)
PS: I want to make this because there a synonym/dictionary website that slowly consumes 5GB of RAM even if it is left inactive for half an hour.
The only way is using alert() or prompt(). Enter may be used to confirm and continue executing.
Chrome extension has API for this.
Tab discard
chrome.tabs.discard(
tabId?: number,
callback?: function,
)
Add permission tabs if required.

How to debug a tab in Google Chrome that freezes right from the browser start?

In a vue web application, I have the issue that I have some deep links (example.com/app/some/123) that are handled by the application (vue-router).
Sometimes (not always), for whatever reason when clicking such a link (in Outlook or from a desktop shortcut) when no browser window is opened, Chrome starts but immediately freezes (tab becomes unresponsive).
It feels like there is some redirect loop going on in my application code that causes this freeze. But my issue is that I have no clue on how to debug this to find the spot:
Opening the devtools is possible using the menu but JS files/code does not "load" - Scripts tab stays empty
Clicking the pause button does nothing, the same applies to pressing F8 (pause script execution)
The profiler cannot start (stays at "initializing").
I also have the feeling that this happens when a new version of the app (js bundle) is published but Chrome has some previous version cached. It feels this more often produces the issue. But this is just a guess.
Clicking the pause button/F8 is my regular procedure to tackle such things to find the spot where we are in the JS code at the moment. But unfortunately, here, this does not work as most of the browser is unresponsive.
The only way to close Chrome is to kill it via the task manager.
Is there any way to enable additional logging via Chrome settings or activate an "immediate debug session" right when the browser process starts to somehow get closer to the JS code that freezes the whole tab?
So ideally that somehow, right from the browser start, a profile of the "debug session" is saved even if the browser is process-killed that can later be inspected?
You could try webQsee (https://chrome.google.com/webstore/detail/webqsee-web-sniffer-recor/gamdpfnfkjknkimfbboonmgdfnondfme). The extension provides some usefull export features that might help you identifying the root cause.
Event Snapshot
Exports Screenshot, Cookies, Network and Console output. A lot of info but it is a proprietary format, in can only be analysed in the extension itself.
Excel Export
Like an HAR export, but also including Console output.
These two export options (and more) are available via the export menu located at the bottom of the extension window.

Prevent Chrome 80 from freezing tab with my page

I have a simple html page that displays some monitoring results, it reloads every 2 minutes and makes noise when those results are not acceptable. I keep this page open 24/7, so new Chrome started freezing and suspending it, as I found out via chrome://discards/ .. So the page stopped making noise and catching my attention, mostly cause the tab gets frozen by Chrome. That happens if I forget to leave the tab with this page active, "on top". Is there a rather simple way to prevent Chrome from freezing the tab, even if it is not active? I could involve some Javascript, if needed..
I am aware that there is a simple solution of opening new window with this page and leaving it alone. On the other hand, I made the page, so I can make changes to HTML in order to ensure that page remains unfrozen. I tried updating title with current time on every reload, this visibly helped, page seemingly always has fresh time in the title, but it still doesn't make noise. And if I switch into it when noise is supposed to happen, - it starts the sound half way like it was trying to all alone.. it's even funny..
Is there any simple solution to this? Thanks for your help.

Debugging my app with Chrome - sometimes chrome takes a very long time to refresh. Clientside hang - not server

I'm building a web application using WebRTC. A very client-heavy app. When I make a code tweak and refresh, occasionally chrome takes minutes to actually refresh.
This is not a pending server response; I see all requests are returning quickly.
Something clientside is hanging up the refresh. Is there a way to force refresh (I've tried hard reload/etc) and stop whatever the tab is doing in its tracks?
You can use the Chrome Task Manager to kill a tabs process, to access the task manager simply right click on the top bar next to your tabs and select "Task manager" from the drop-down.
From here you can find your tab and kill the process (by default the open tab will be selected)
This will make the tab display the chrome://crash/ page, where you can then happily refresh the page.

How does Gmail force itself to become the active tab when it's done loading?

I've never seen another website do this and it's interesting behavior. To recreate it, open a new tab in Safari and go to mail.google.com. While it's loading switch to another tab and wait. Once Gmail has finished it's ajax loading it fires what I presume to be a javascript event to force it to become the active tab.
Does anyone know what the javascript event is? Is it possible it's not javascript?
Everything that you need about safari javascript extentions is there:
http://developer.apple.com/library/safari/#documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html
I checked, they talk about how to set a tab active.

Categories

Resources