setInterval not working properly on safari web extension - safari

I've recently ported my chrome extension to safari using the safari web extension converter: https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari.
However, I'm finding that my setInterval calls only executed a set number of times in the background page. When I open the background page for my web extension, I've tried running a simple interval to see the result:
Safari Web Extension Background Page with interval stuck after running set number of times
When I try the same thing for my chrome web extension, the interval runs indefinitely:
Chrome Web Extension Background Page with interval running continuously
If I try to run the interval after opening the dev console for any random web page in Safari, the interval works fine:
Safari content page with interval running continuously
Similarly, a recursive setTimeout function fails in the background page for the web extension:
Recursive setTimeout function in my background page
Result of recursive set timeout function in my background page (stops afterwards)
I'm not sure why timers might be failing in background page for Safari. My extension works perfectly fine in chrome/brave/firefox. Thanks!

When the extension is not active safari browser stops the background process of that specific extension.
Alternative approach: You can create a timeout in the content script and message background from the content script periodically to check your requirement.

I saw the same issue. setInterval() was throttled after 6 iterations, no matter the interval. Calls were made, but sporadically, like once a minute at first and even further apart later.
I fixed this by switching to alarms API instead of setInterval(). Seems to work fine.
Safari 16.3, macOS 12.6 Monterey.

Related

Opera only shows notifications when switched to a different tab

I'm trying to setup Notification api in Opera Browser. My code works in Firefox, Safari, and Chrome. It does not entirely work in Opera GX.
When the notification is created, the banner is only shown after the tab has been changed. It doesn't matter how long ago the notification was created, nor does switching to another application trigger the event. Only selecting a new tab.
Is this expected behavior?
Can I fix it with js?
Can I fix it within Opera GX?
EDIT: peculiar details. It does not trigger the notification when switching to another tab on localhost. Also, the one I'm triggering from is https://localhost:1234 (not an iframe, is https)

Chromium on startup behavior is different that launching it manually

I have a Jetson Nano that runs LXDE. After booting it should automatically start Chromium in kiosk mode and launch a web page. The web page is very simple, just adding and removing some rectangles or images based on web socket messages.
Since sometimes the DOM gets updated, sometimes not, I thought my web page has some bug. But this behavior is only on the Jetson Nano. Furthermore, when I launch the Chromium manually with the exact same parameters, I have no problem at all, everything runs as expected.
I also observed that the Chromium (the autostarted one) instantly updates the DOM correctly when I press Alt+Tab (since it is the only application, no application is really switched). So apparently nothing has happened since the last web socket message, I just press Alt+Tab, and the web page instantly is displaying the correct things. Additionally it is very difficult to bring up the developer console, pressing ctrl+shift+i for several minutes, when you are lucky it fires up the developer console. Once it is there, the web page is again working normally.
I have no idea what I can do about it. I just want to launch the Chrome so it behavior is like when I start it normally.
Currently, the autostart is done inside ~/.config/lxsession/LXDE/autostart with the line #/home/agx/dev/autostart/chromium.sh, this file is:
#!/bin/bash
sleep 60
chromium-browser --new-window --password-store=basic -kiosk --js-flags='--jitless' http://192.168.1.50/index.html
I tried to delay the start hoping it would help but it changed nothing. Same for jitless. I can execute exact this command manually in the console, chromium fires up and behaves normally.
How can I trace this one down?

My site does not load on new Safari version 15

My ruby on rails website does not load on safari 15. It works fine on older versions as well as other browsers. The below is what I see in Safari 15
There is nothing in the console logs or any indication of what the "problem" is. Interestingly this is also an issue for my site if I run it locally on localhost:3000 which leads me to think it's an issue with something in my sites code.
If I disable Javascript the site will then load, what in my Javascript could cause this?
I have a similiar problem with my matured React app. Some users of my web application are using Safari 15 and they report that some fragments of the application are not loaded.
I also got screenshots from them. There is nothing indicated in the console.
But interesstingly all the HTML canvas elements are not rendered. Even the small ones.
Some examples:
Leaflet map in canvas (map tiles somehow not rendered):
A chart in a canvas (chart stays blank):
I mean it is working in every other browser since years and also Safari 14 and Safari on iOs.
Must be something Safari 15 realted.
For me this ended up being an issue with Three.js, I needed to upgrade it's version then the site worked in safari. If you're not using Three.js, then I'd recommend checking the other JavaScript packages you are using.

IE11 not responding due to long running scripts

My application is working fine in all browsers Chrome , Firefox , (except ie 11).
We have a loader that is common for Ajax calling. It get stucks or hangs at some controllers randomly.
IE 11 is displaying a message on the footer "localhost is not responding due to a long running script" .Also note the application is working fine .Assuming this is some thing specific to IE 11 .
Any idea would be appreciable .
Thanks,
Avi Verma.

Chrome Headless - Firefox

I'm working on a monitoring tool for my website to log data. The actual logging is made on server. My goal is to calculate stats based on how long the user stays on the website.
Main question: I used chrome headless command --remote-debugging-port=80. I got logs for up to 10 minutes. Works perfectly. But how long will it work if left working? Is there a default timeout? If yes, how can I change it? If I want to run it exactly 30 minutes after page finished loading?
I'm trying to do the same on firefox (tried using PhantomJS but it wasn't loading the page correctly even though useragent was set to firefox) but firefox just throws an bank page when I'm trying to start a headless mode. I used "firefox -headless" and tried capturing an screenshot. It was just exiting my currently open firefox tabs without capturing any image. Any idea?
Using firefox quantum 59.0. I don't want to use selenium.
Also PhantomJS solution would be great. Currently I just want to collect logs. So, it only have to run all javascript (an jquery) code on the page which then sends the data using ajax. I tried page.onLoadFinished and then a wait function to make it stay on the page for the exact time after page loading.
Since no one answered, I will try to answer my own question after even more research and logical thinking.
Main question: Seems that there is no timeout but if need can be used --timeout X. Even though it's not perfect because it runs independently if the page if fully loaded or not.
As for the firefox, it's buggy. -new-instance (make headless run while you are already on firefox) is not working and -no-remote didn't help. Firefox is only working if running only one instance. So, if it's the PC you are working on and you want to run tests too, firefox is not for you. Headless runs only when no other instances of firefox are running, while chrome runs fine.
PhantomJS didn't work even though tried multiple solutions.
Best solution? Use chrome. Need portable? Use chromium and use headless. Or write your soft to use cefsharp which is based on chromium. Your browser with all libs will be around 120-200MB. Pretty big for portable but do it's work. Same as portable chrome or chromium. CefSharp have a privilege of integrating whatever you like into the browser since it's a... browser.