Too many threads in Blackberry using Phonegap/WebWorks - javascript

I am developing a Blackberry app using Cordova/PhoneGap. I am fetching several images (map tiles) from a server. Also, every 60 seconds I send position information to it.
However, every now and then either when I fetch the images or send information, I get an error. If I am on a simulator (BB 9930, OS 7.0.0.318), I get an AppError 104: Too many threads message and my app crashes. When I test my app on a device (BB 8520, OS 5.0.0.592) not only does the app crashes, but makes the BB reset.
I have seen other posts with the same issue (like this one, this one or this one). However, I haven't found a solution when building the app using Cordova/PhoneGap (JavaScript).
Thanks!

This may not be related, but I did have a similar problem when doing a lot of request from a native app on a BB Bold. The connection thread was not closed properly after receiving the answer.
try the following:
change GET <-> POST.
change HTTP <-> HTTPS.
if the server is yours, evaluate changing the API to return all the images as one and use an offset/clipping when displaying them. You will save bandwidth and open less connections. your app will load faster.
eg:
http://www.ibloomstudios.com/articles/misunderstood_css_clip/

I doubt if the phoneGap API is causing this as it is basically a layer. Possibly you have an issue with the simulator?

Since you are also testing on Blackberry 8520, It is recommended that you keep the MAX number of threads - running concurrently- at any point of time in your application - less than 12
Since you are using Phonegap, chances are that it may be initiating those threads for your application.
If the device is connected to your system, connect it to Blackberry JDE and see, which threads are active to analyse if you can reschedule your tasks.
Are you using AJAX to get the map tiles and send location to your server?
If you are using AJAX, then you can keep a counter in JavaScript to keep a check on the requests.
Also, have you tried WebWorkers , they would enable you to do all of them within single thread itself.
If all fails, you can also develop your custom Phonegap plugin to do similar things with a Java Script interface API.

Related

Is there an easy reliable way to transfer a file over local network using Electron / Node.js / terminal?

Are there any built-in methods in Electron / Node.js allowing to transfer a file over local network to another device?
I want to be able to send files locally from one computer to another (through an Electron app), but I also want it to be able to send files to smartphones.
How do I do it? Is it possible to just create a temp local server and download the file from another device by opening the URL (e.g. 192.168.0.x:x/file.txt)?
I tried using https://www.npmjs.com/package/quick-transfer which does exactly that, but for some reason opening the link on another device doesn't do anything.
As painful as it is for me to suggest... I'd recommend WebRTC for this, for these reasons:
It will make a local connection, when possible.
It will work over the internet as well, if required.
You can work around any firewall difficulties with TURN.
You will have compatibility with browsers.
You won't be opening up some server to a file that anyone on the network can get... transmission occurs over a secured connection. (This doesn't mean you can ignore other security aspects in your application however!)
Sample code: https://webrtc.github.io/samples/src/content/datachannel/filetransfer/
Commentary: It's amusing to me that in 2018, we still haven't solved the problem of sending a file from point A to point B. Network Neighborhood in Windows was the golden age, and now it's all screwed up with this newfangled cloud crap. :-) Obligatory: https://xkcd.com/949/

Cordova hybrid app- HTTP requests are very slow

I am building a hybrid app, with AngularJS, Cordova, Restangular ond client side and Python with wsgiref.simple_server on server side. I am not doing anything special, this is very simply requests like this:
Restangular.one('/devices').get().then(function (response) {
viewModel.devices = Restangular.stripRestangular(response.devices);
});
I set baseUrl for Restangular:
.config(function(RestangularProvider){
RestangularProvider.setBaseUrl('http://192.168.54.102:8000/');
})
And when I use it on local computer with Chrome browser, everything is fast, works normal. But when I use it on Android on Phonegap developer app on device or install app on device with Android, it works crazy slow. It looks like it is send to server with big delay, cause it takes some time as I see debug server log on server side. It occurs also when python application with server is not in debug mode, for example when I start it normally after install on local computer. As I see some people has this problem, does anybody found a solution or a reason, which causes very slow HTTP requests in hybrid application? Thank you in advance for every answer.
Since you are a hybrid developer, I am sure you are familiar with the Chrome DevTools. For me on a Mac, hit cmd + option + i, or go to View -> Developer -> Developer Tools.
The really great thing about Chrome in recent history is it now works with Android WebViews too. Hybrid developers haven't always had this convenience, and had to debug essentially handcuffed using tools like Weinre.
Now we can use the DevTools directly in the Chrome browser while your Android device is connected by ADB from a new tab calling chrome://inspect
Here is some more detailed information on how to do this if you get stuck.
From here open up the network panel and see how long your requests are taking. If they are showing a significantly longer amount of time to load here, the issue has nothing to with Angular, Cordova, Restangular or probably even Hybrid architecture at all. I would check your network and performance elsewhere on the device.
If this is definitely not the issue, I would use the Timeline tab in the DevTools to see what is taking so long between your browser receiving the information and your device displaying it. If there is any significantly longer process taking place in between, you will see it here.

Background Application on Smart TV

I have an application on Samsung Smart TV. I'm fetching data from web service and display this data in my application.
I'm fetching the data periodically and updating the application accordingly.
I want to run this operation as a background process, so it'll download the data and if there is an update, I warn the user when s/he watching TV.
The other thing I want is to start application on TV launch, is it possible?
Only 'ticker' type application can run in background. It is not supported in Europe and will not pass certification for Samsung Apps store.
Samsung Smart TV suppots push-notifications (samsungdforum.com/Guide/art00080/index.html).
It will allow you to show popup-message on screen with ability to launch your application.
You cannot auto-start application on TV launch.
The only way is to use custom firmware like SamyGo (http://www.samygo.tv/)
About the "background process"... as far as we assume that JavaScript's setTimeout or setInterval can be used to execute application's "internal" background process, there is no problem - Just DO it! :)
But if you were thinking about system's background process - for ex. crontab of device - it's impossible.
for your second doubt
Auto launch of the application is supported in ticker applications only and there is property in config file of the ticker widget :
"<ticker itemtype="boolean">y</ticker>"
if u mark it as y(as above) than you can set up auto launch of the app from
Menu->smart Hub->Apps settings->auto ticker. in 2014 Samsung Smart TV models.
Since Tv has limited memory I wont recommend background process like setInterval or setTimout. You may have refresh button for the same.
And They must have some js api for controlling internal method of tv application (not sure). Anyway if you really want to use interval/timeout dont forget to clear it.
As it shown here, WebSocket is supported by Samsung Smart TV. Your server application can trigger TV application when an update is appear. It is more efficient way than polling server with ajax for your case.
(Edit) I wrote a sample application to demonstrate:
https://github.com/aksakalli/socket.io-hello-world
(Edit 2) I see that your problem is about platform limits. My answer is just about approaches that can be applied then I have very limited experience on Samsung Smart TV.

Constant Client Disconnects in Classic ASP Web Application

I'm working with a Classic ASP web app that typically runs well considering the old technology. It is an online support chat application that basically refreshes the client side Live Monitor page every 10 seconds to see if there are any pending chat requests. The past few days, a lot of our users are having a problem where this page either just ends up refreshing and going blank white (with no html in view source), or it goes to a generic IE error page "This program cannot display the webpage" - the same error you see when you are offline. I was able to recreate the issue after hours when I was the only user in the chat system, so it's not a matter of an overloaded server I don't think.
I've tried the following to no avail:
Recycle Application Pool
Reboot IIS Server
Change refresh from javascript to meta tag
Check IIS Error logs (nothing)
Check IIS event logs (nothing)
One thing that seemed to work for me, but didn't work for everyone else, was to disable our network Proxy server settings in the browser. Once I disable this, I can't get it to error out anymore... however, other users aren't quite so lucky.
Any thoughts on where to go with this? I'm at a bit of a loss here...
Thanks,
Shawn
We are finding the same problems in a .Net solution. It looks as if the issues are related to SQL Locking so we're working on those as we find them.

How might I send messages (strings) from a Win32 app to a Javascript program running in an existing IE window?

I have a system tray icon that receives incoming phone calls. When a call comes in, I want to send the phone number into a web app that does stuff on that phone number. We can launch the web app with the phone number in a query string, but if I launch a new window for every call, it will junk up the user's computer with lots of browser instances, would not preserve the location/size the user moved the browser window to, and would take longer than just refreshing the page. Instead, I'd like to make the Win32 app re-use the same IE browser window and just send the web app the new phone number every time a new call comes in. I'm envisioning somehow sending a Windows message, or somehow instructing the IE browser to run a certain javascript event with some data? I can see why doing the reverse (javascript out to Win32) would be a security issue, but this would be just sending a message from Win32 to javascript.
So I'm specifically NOT asking how to do what's been answered in this question: How to Interact Between Web App and Windows Form Application
That user was asking how to launch a Win32 app from Javascript and pass data to the win32 app. Roughly, I need to do the opposite. I need to send data from a Win32 app into a running javascript program.
Note also that I'm not asking how to launch one IE window with arguments to Javascript one time; I can easily do that with query strings. What I'm asking is how can I / is it possible to pass data from a running Win32 app outside the browser to a running Javascript app inside a browser window.
Since you can send the phone number to the site through a querystring, all you really need to do is tell IE to navigate to a URL of your choosing.
To that end, you can use what is in this KB article to help you find the instance of IE you want to connect to.
http://support.microsoft.com/kb/299356/de
Granted, its in Visual J++ of all things, but since you are interacting through COM Automation, the calls should be easy to translate.
Once you have the instance of IE (in the form of an IWebBrowser2 interface implementation) you can simply call the Navigate or Navigate2 method with the URL you need (with the phone number in the query string of course).
You should be able to find the handle of the IE window, and then send messages (keypresses perhaps) to it. Use a bit of javascript to capture all keypress activity and you have a very simple method to transfer information.
It won't be easy (the devil is in the details - issues of focus, etc) but it should be possible.
-Adam
What you need is a way to How To Connect to a Running Instance of Internet Explorer
(caveat: this one is in Java, but you should be able to translate it to C# quite easy).
Or you could enumerate the top-level windows to find a particular instance of IE and then Get IHTMLDocument2 from a HWND (this one is in C++, so you might need to do some Win32 interop; you can find all necessary declarations on PInvoke.net).
If you search on your friendly local search engine for How to connect to a running instance of Internet Explorer, you will find a lot more info.
Once you get to the document, you can either invoke the JavaScript function through the document scripting interface, or you can just navigate it to your page and pass the phone number as a parameter.
you could possibly get around the security and other issues with this method by using a web service on the web server, and have the win32 app update the web service and have the web page poll the same web service every however many seconds. Then you the the option of mapping that number to a database and getting additional information.
The only draw back is that instead of being immediate, there is a delay to get the information displayed in the browser.
How about you write an active-x control that you create in the browser using Javascript. This is effectively an Explorer browser plugin. Same idea for Mozilla, etc., except they use a different plug-in structure. This lets you support other browsers in the future.
The control can talk to your win32 app using a pipe or a socket or whatever type of inter-process communications and is then accessible as a Javascript object.

Categories

Resources