If the browser is minimized or Tab changed, Plugin to UI Callbacks were executing after 30 Seconds Delay from the extension layer

21 views
Skip to first unread message

veerendra k

unread,
Oct 10, 2018, 9:26:06 AM10/10/18
to firebreath-dev
Hi,

We have Message alerts in UI layer,  for showing the Message alerts  we have the setup like (C++ plugin>>firebreath extension>> UI).

We observed that The message flow from plugin is  PluginLayer >> Firebreath extension(background.js>>content.js via post-messages) >> Webpage

1. Why the 30 seconds latency  if i minimize the browser ??

My requirement is, even if i  tab-change or minimize the browser, UI layer should get(callbnacks) called from extension layer, now its happening after exactly 30 seconds.


Why the 30 seconds latency, i have debugged the extension code but couldn't able to find exact reason. 

debugging info: once we posted the messages to webpage from content.js using 

window.postMessage({
            source: "host",
            port: portName,
            ext: extId,
            message: "Created"
        }, "*");
        port.onMessage.addListener(function(msg) {
            // Message from the background script received, post it to the page
            msg.source = "host";
            msg.port = portName;
            msg.ext = extId;
            window.postMessage(msg, "*");
     });


 in the same we are listening to message 

window.addEventListener("message", function(event) {
        // We only accept messages from ourselves
        if (event.source != window) { return; }

        if (event.data && event.data.source && event.data.source == "page" && event.data.ext == extId) {
            handleEvent(event.data);
        }

        if (event.data && event.data.firebreath == firebreathId && event.data.callback) {
            initPage(event.data);
        }
    }, true);

This is the end point from extension layer..


Could you please clarify above mentioned question.

Thanks in Advance..


Richard Bateman

unread,
Oct 10, 2018, 11:52:24 AM10/10/18
to FireBreath Dev Group
Hi,

Some time back browsers (including Chrome) started throttling some javascript in background tabs in order to reduce battery usage on laptops; since that time it seems that all messages including native message host messages move very slowly. There is nothing we can do about that unless the browser developers give us a way to tell the browser to speed up.

Richard

--

---
You received this message because you are subscribed to the Google Groups "firebreath-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebreath-de...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

veerendra k

unread,
Oct 12, 2018, 4:58:53 AM10/12/18
to firebreath-dev
Thanks for quick response.

I found a way to get callbacks immediately even the tab is not in focus(minimized or tab changed).

I modified the FirebreatPromise.js as below

//function defer(fn, arg) { setTimeout(function() { fn(arg); }, 0); }

function defer(fn, arg) {  fn(arg);  }

Please suggest me is it right way to do?

Thanks in Advance.

Richard Bateman

unread,
Oct 12, 2018, 9:56:36 AM10/12/18
to FireBreath Dev Group
Interesting; that change breaks the Promise/A+ spec and will absolutely change some behavior, but it's hard to say what actual consequences it will have when most of the messages start in an asynchronous manner.

I would be very leery of making that change, but it might be adequate to your need.

Richard

veerendra k

unread,
Oct 13, 2018, 11:39:30 PM10/13/18
to firebreath-dev
How about creating a worker instead of timer  and push all messages in Worker thread execution. is this right solution??

Thanks in Advance. 

Richard Bateman

unread,
Oct 14, 2018, 5:04:13 PM10/14/18
to FireBreath Dev Group
I'm not sure what you mean exactly; the line you're talking about is the Promise library that FireWyrm is using in the browser. you could replace that with Bluebird or any other Promises/A+ compliant library and it would work just find, but the setTimeout is specifically talking back to javascript inside the page; I don't know how sending those messages to a web worker would help.

Richard
Reply all
Reply to author
Forward
0 new messages