firebase offline lost focus on input - javascript

I've a web app on iphone developed with a firebase backend (JavaScript client v2.2.4)
When I open the app with airplane mode activated (no network) the app is loading fine, everything is cached with a cache.manifest
I can see in the safari's console that the firebase client is making calls to my firebase backend. Those calls are failing because I don't have any network.
the calls looks like this : /.lp?start=t&ser=17611300&cb=10&v=5
The issue:
If the user put the focus in a textarea, the focus is lost everytime the firebase calls are failing, which is very annoying for the user
Any idea how to avoid this behaviour?
The specificity of my use case:
I'm offline
The user put a focus in a textarea

Here is a workaround
I found that /.lp?start=t&ser=17611300&cb=10&v=5 is for long pooling connections
Websockets is enough for me, so I force the websocket only with the following code
Firebase.INTERNAL.forceWebSockets();
The problem vanished

Related

client side signalr is slowing down application in browser

Need your guide, please.
as shown in the diagram I have integrated Azure Signalr chat in my application through client-side scripts. it is causing slowness and crashing in the browser due to insufficient resources.
this only happens when signalr script is enabled and signalr connection is in use.
otherwise, the application is working fine.
We also have a separate chat application that works perfectly fine with a large number of users.
The issue is happening in the client application only when we are testing with 80 to 100 users. in reality there are thousands of users who will use signlar chat. I am worried about how this signalr will work.
Note: I have managed to limit single signalr connection for each user even in multiple tabs. but onclose event is called after few intervals so I have to call start function which is a normal thing. but cause of onclose event is not known. There is not internet glitch.
can somebody help me how to figure out the cause of onclose function and how I can manage to make signalr work without slowing the client application
There is only a slowness issue. no 400 or 500 error.
Thanks

How to debug WebSocket / Server Sent Events reconnections on desktop?

I am developing an app that uses Server Sent Events (SSE - basically one-way websockets). If the user uses the site on their mobile chrome browser and then tabs out for about a minute, the SSE connection breaks. If the user then tabs back into the site, it doesn't refresh the page (this is good). But I still need to re-establish the SSE connection so that the server can resume sending messages to them without a refresh.
I'm trying to debug my implementation but having to do it on mobile is very tedious. I have to grab my phone, refresh the page, then tab out, wait 1 minute (so the connection can break), and then tab back in to determine if my code for re-establishing the connection worked properly.
I would much rather be able to debug this on desktop, but I haven't found a way. I have tried the following:
Tried 5 different Chrome extensions for sleeping a tab. Unfortunately, when you navigate back into the tab it just refreshes the page rather than resumes it.
Tried using USB Debugging, but the desktop keeps the tab open at all times even if you tab out on mobile, so the tab never sleeps.
Tried running debugger; in the Chrome Developer Tools console, but even if I let the Javascript sit with its execution frozen for 5+ minutes, it never breaks the SSE connection, so I can't test if reconnecting works.
Tried using an extension to kill the internet for Chrome, but miraculously, this still maintains the active websocket/SSE connections. Apparently Google engineers have deprioritized this effort?
Basically, I am looking to simulate the behavior that happens on mobile when you tab out of your web browser, wait a minute, and then tab back in (the Javascript execution is frozen, the SSE connection is broken after a minute or so, and then tabbing back in resumes Javascript and attempts to reconnect the SSE connection).
Is this possible?
I think that best change you have by emulating your android device. You can do so by installing android studio from https://developer.android.com/studio and then here you have all you need to start and manage your virtual android env https://developer.android.com/studio/run/managing-avds
This it the way I debug my whole mobile development
The most obvious solution to me would be to attach a listener that tracks the events related to tab activation and build some custom solution upon that.
Simply:
window.onfocus = () => {
// Restore SSE session
};
window.onblur = function () {
// Inactive
};
Just for info, SSE is a different protocol from websockets.
In case you are interested in using websockets implementation, I suggest the following library which works very well in my experience: https://www.npmjs.com/package/#stomp/stompjs
Stomp is an abstraction over the websocket protocol, but it also means you would need to implement this on the server side as well.
You can use the chrome://discards to freeze your tab.
You should close and restore the connection based on the Page LifeCycle events.
You Can Try to use pause execution
goto:
Chrome javascript console (Ctrl+Shift+J) > sources > pause script (press f8)
This simulates like a mobile tab switching so you can debug easily
I think this is the simple and easy solution. thanks

Rebooting Tizen display will often not cause update

we are developing a web application (HTML/CSS/JS) on Tizen SSSP4 and SSSP5 devices.
According to SAMSUNG changing tthe version number of the application in sssp_config.xml will cause the display to update next time the application is to be launched.
However when I update the app version and reboot the display using
b2bapis.b2bcontrol.rebootDevice
it will sometimes update, yet other times it will not. Usually it will not update on the first time, yet update if I call the same API once more after the display has restarted. Sometimes the display will get stuck and no longer update even if I reboot multiple times using the API.
I checked the web connection, which is fine. The display is connected via cable, between the display and my server is but a switch. Also I see the display in WEINRE using a webhook all the time.
Has anyone encountered this problem? What can be done to resolve this? Is there something that must be done when unloading the app in order to release the API properly?
Thanks.

During a Firebase outage is there a way to simulate this by running local code

During a firebase outage my app had a very poor user experience with things just not loading. Is there a way to run some local code to simulate this experience so that my app doesn't crash and burn during the next outage? I'm currently using the javascript SDK.
I managed to reproduce the results fairly easily by adding overrides to the socket connectors in my /etc/hosts file
127.1.1.1 s-usc1c-nss-215.firebaseio.com
127.1.1.1 s-usc1c-nss-222.firebaseio.com
You can pull this location from your network WS tab in chrome to see what needs to get overwritten

web app on mobiles with phonegap

I have a web application (chat room) in html + javascript that basically sends requests to the server every 5 seconds to check for new messages.
It already works on mobile but there are 2 main problems:
it does not beep (it works on pc) with new messages
when the browser is put on background, the javascript obviously stops being executed, therefore the connection to the server is lost and the client disconnected.
i was thinking of using phonegap not only to make it cross-platform but also to fix those problems stated above. would they be resolved with the use of phonegap?
thank you in advance.
phoneGap doesn't support custom push notification. it basically open a browser and expose you some native support via API.
in order to do some native actions like push notifications and/or sound playing i suggest you check out some of the plugins options available or even write your own for that.
Playing sounds can be done easily using the Media API. As for having the JavaScript run in the background it really depends on the OS. On Android the JS will continue to run if you leave the app via the home button but the back button kills the app so you would stop the JS. It is probably better to write a service that always runs in that case.
Alternatively you'd look at a push type solution to notify you of new messages.

Categories