how to manage tab loader in browsers? - ajax

I'm trying to manage (when to start and stop running) loader that appears behind the tab name, the loader indicates that there is requests behind the seen, any help?.tab loader

Related

Does closing the Application browser window ends the processing that was happening in Spring MVC

In a Spring MVC app, if a page (browser window ) is closed while a functionality was running, will it stop the application and the processing that was happening or it will continue to happen at the server.
Suppose I have a functionality to export an excel report , I click the Export button. Now there are 2 cases :
Case 1 - If I initiate report generation without using thread , and close the window before report generation, would it throw the error/or abort the report generation OR would the process continue to happen on server and report will be downloaded?
Case 2) If I would have initiated report generation using a thread , and closed the window before report generation , would it throw the error /or abort the report generation OR would the thread continue to work in background and report will be downloaded?
The short answer is no, closing the browser tab or window will not affect the processing that is happening on the server (unless this processing also involves I/O with the client).
In general, Servlet containers (e.g. Tomcat) that host Spring MVC applications have a built-in thread pool to service the http requests. Once a request arrives, one of these threads will process it. If in the meantime, the TCP connection is closed by the client (which is what hopefully1 happens when closing a browser tab or window), the thread will not be notified or interrupted in any way. Therefore, any processing that might be happening on the server side will continue. I doesn't matter if you use another Thread to do the processing or not. The processing on the server will continue in both cases.
Since you are specifically asking about "downloding" a report file, here is some more info: Downloading involves I/O with the client. If you close the tab or browser before the download begins, the server will get an error as soon as it tries to write the data to the response. So the file will not be downloaded, data will not be transfered. If you close the tab after the download begins, the file will be downloaded normally. If the user cancels the file download, then again the server will get an error and data transfer will stop.
In any case, if the generation of the report happens before sending data back to the client, the generation will continue to work in the background, regardless of whether you use a Thread or not.
1 I say hopefully because the exact behavior depends on the OS / Device / browser. Closing the TCP connection would be the expected behavior.

Plugin Development - Embedding Custom Framework to XPC

I have recently created a custom framework that is planned to be re-used for multiple projects. The catch is, this is for a plugin, and knowing that we can't simply embed the framework within the plugin's bundle, due to symbol collisions and what-not, I'm thinking of simply embedding it with the plugin's XPC. On a side-note, this framework will be used to launch custom interfaces, such as a view controller, views, and use some delegates slapped inside it that the plugin will have to take ownership (which I am hoping). Which brings me to my question: is it possible for a different process to take ownership of objects instantiated in the XPC? I am quite new to using frameworks, so I've spent hours trying to jerry-rig stuff together in XCode based on tutorials I've found online, sadly to no avail.
A framework is a bundle of code and resources that can be used, and reused, by multiple applications. It can be embedded within your application, be part of the operating system (the entirety of Cocoa is actually a collection of frameworks), or dynamically located and programmatically loaded at runtime. Once loaded, the framework's code, classes, and resources appear to the application as if they had been compiled directly into the host app. The key is that the code executes directly, in your process's memory space.
XPC is an inter-process communications facility. It allows one process to send and receive messages with a different process. It cannot be used to communicate with itself.
You cannot "take ownership" of an object using XPC. All XPC messages serialize ("archive" in Cocoa-speak) any object and de-serialize that object on the receiving end. The second process now how a replica of the original object; it is not a reference to the original object and is constrained to the boundaries of its process.
If your second process needs to display something, you have (basically) three options:
(1) Make the second process its own application. The second process can be a full-fledged Cocoa app with windows and so forth. You can make it an "accessory" app, so it does not have a menubar or appear in the dock. See LSUIPresentationMode Info.plist property and/or NSApplication.activationPolicy.
(2) The advanced technique is to use an IOSurface. An IOSurface is, essentially, a method by which a second process (your XPC Service) can draw directly into a window of your application. Again, the drawing objects still exist—and are completely isolated in—the second process; but what they draw will appear in your application as if they were local view objects. (This is how Safari works; every browser page is rendered by an isolated background process drawing into a surface.)
(3) Use a poor-man's IOSurface: send your data to the second process, have it render the results into something (pixel array, TIFF, PNG, ...) that can be serialized and drawn by the host app, then use XPC to send that rendered image back to the host app for display.
Daemons and Services Programming Guide
IOSurface

How to debug web worker script under electron?

I'm writing a debugger tool using Electron (I'm creating my own UI, so I don't use the built-in DevTools).
I'm using win.webContents.debugger to access the debugger instance and I can control my renderer.
The problem is when the renderer creates a web worker:
new Worker('script.js');
I don't receive any debugger related events to it nor can I access it (I can access it when I use DevTools, but I not using the debugger instance).
How can I access and control my web worker with the debugger instance?
EDIT: I've setup a demo project to demonstrate the problem: https://github.com/giladno/electron-quick-start

How to run a service without being depending on activity going to background

I'm building an application that must does the following
when the user opens the application, the application starts (in the background) searching for some places using GPS and WiFi. and gives the user a notification when finding a location.
The searching process must start working in the background when the MainActivity launches, not when the MainActivity become in background
and mustn't stop if I finished the MainActivity,
it shouldn't stop also if the user opened another application.
It may only be stopped when the application is closed.
I searched for a way to make these four steps and I found that I can use services to run my code in background, but the problem with services is that it's bounded with activities; if activity is destroyed then the service would stop working [xamarin documentation].
How can I achieve those five conditions?

What would cause an application to crash on subsequent start up when managed resources are not disposed?

I’m working on an application for a motion tracking device and have discovered some odd behavior that got me curious. The device SDK consists of three DLLs, one of them (the main referenced DLL being used in the application) non-native, and the other two native.
The application has three main actors, the Controller (connection between device and application), Listener (receives tracking information) and an endless stream of Frame objects (the data the Listener receives). All these items are disposable, in turn I believe they use unmanaged resources.
If I do not remove the listener from the controller and then dispose of the controller, the application will crash on subsequent startup. This behavior is sporadic, it might happened at the second, third or later startup.
Although I am making sure I am disposing the objects, I’m still very curious what logic or lack of logic can cause this type of behavior. Because I expect all objects to be disposed when an executable stops running.
Could the device drivers hold onto a reference? And what would be the best way to troubleshoot this?
So the question is not how to dispose, but what would/could cause this, and why- and how can I Sherlock Holmes this.
More information:
No exceptions
Attaching a debugger doesn't provide more information

Resources