in a PC game I have ingame browser used for news, virtual currency shop and social networks. It's built with quite fresh update of Chromium Embedded Framework. The problem is when I open a browser window (website is working fine there) and then close, for certain websites CEF sub-process doesn't finish. I also may continue hearing audio, if it was Youtube video, for example. I use offscreen rendering, other native windows are not created, only subprocesses. To close the browser window I remove all references to CefBrowser and call:
m_browser->GetHost()->CloseBrowser(true);
I also tried other ways to close/destroy/finalize that render subprocess, such as loading 'about:blank' before closing, but that was no help: process stayed awake, audio continued playing.
Important note: it happens only on certain websites, which I suppose use some feature, that others don't. When I tried to disable JavaScript in CEF settings, the bug disappeared, but I need JS.
Is there a way to force kill browser subprocess? (Notice that GetWindowHandle returns 0, because it does not have a window)
Is there another way to correctly terminate browser which I don't know?
What feature of the websites may cause such bug?
Thank you!
CEF runtime configuration: multi-process, single threaded message loop, with subprocess path, windowless rendering, no sandbox.
PC configuration: OS Windows 8, VS 2010, Chromium Embedded Framework version 3.3071, build 1649, C++ language.
You should check your implementation of onbeforeunload.
CEF GeneralUsage writes about CefBrowserHost::CloseBrowser:
The parent window then needs to call CloseBrowser(false) and wait for a second OS close event to indicate that the browser has allowed the close. The second OS close event will not be sent if the close is canceled by a JavaScript ‘onbeforeunload’ event handler or by the DoClose() callback.
And if you still want to just kill the sub-process , I would suggest you use the browser IPC message and exit at the app.
At your game run
CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create(KILL_subprocess);
m_browser->SendProcessMessage(PID_RENDERER, msg);
and at the subprocess implement “OnProcessMessageReceived”:
if (msg->GetName() == KILL_subprocess)
{
delete this;
std::exit(EXIT_FAILURE);
}
Related
Background: I am writing a QA automation platform for an API which outputs formatted results to a specified directory. In addition, I have developed a GUI application for analyzing these results. A user may run the second application trying to analyze test results while our automated build system is running the first application modifying / generating new test data. To avoid thrashing, I have each application acquire file locks when making modifications, and releasing them when they are done. Upon normal program termination, if the running application has acquired a lock on the data directory it is released.
Problem: I need to be able to release the aforementioned file locks when either tool exists prematurely (user pressing CTRL-C, user stopping the application in debugger, or due to buggy API / application logic being tested). To handle this, I have implemented a signal handler using sigaction which handles intercepting fatal signals (tested and working), and have implemented a ctrl-c handler via the Win32 function SetConsoleCtrlHandler. However, I cannot seem to find a way to intercept the event of a user pressing the Stop Debugging button in Visual Studio. I assume this event generates something like SIGKILL / SIGSTOP (which cannot be handled through sigaction) but I would also hope there is some std library or Win32 functionality to intercept this event and perform some cleanup. Do you guys know of a way to handle this event or even what exactly this button does to kill a running application?
If you're using boost, you can use boost::interprocess::windows_shared_memory.
It is guaranteed to be released when the process ends.
Boost is just a neat wrapper around the windows API in this case. It wraps the Windows Named Shared Memory API.
Is there some type of notifications that iOS emits when app get force quited?
By force quite i mean tapping the home button while app is in active state and then removing it from multitasking menu.
I want to be able to detect force quit, to gracefully handle everything.
We have an issue like this with one of our games and our publisher wants us to handle this.
This is not standard Cocoa App, this is game ported from PC, written mostly in C++.
This happens only on iPad Mini 2nd gen, when app is force quit-ed it will crash on next launch.
On other devices, when app is activated it will load up properly and continue with proper scene loading order.
Does iPad mini 2nd gen has something different from other devices regarding development?
Crash logs says that app crashes immediately after force quit, well duh...
- (void)applicationWillTerminate:(UIApplication *)application
is not really useful, it doesnt detect force app quit.
The idea is that your app should handle termination the same regardless of whether it was initiated by the operating system or by the user. You are encouraged to save the app's state and reload on the next start. And it's probably a good idea to save state when your app is sent to the background because according to the second paragraph below, applicationWillTerminate is not always called when the system kills your app.
According to the documentation
This method lets your app know that it is about to be terminated and purged from memory entirely. You should use this method to perform any final clean-up tasks for your app, such as freeing shared resources, saving user data, and invalidating timers.
Also
For apps that do not support background execution or are linked against iOS 3.x or earlier, this method is always called when the user quits the app. For apps that support background execution, this method is generally not called when the user quits the app because the app simply moves to the background in that case. However, this method may be called in situations where the app is running in the background (not suspended) and the system needs to terminate it for some reason.
I'm trying to develop a browser plugin using Firebreath framework. The first thing I would like to achieve is to make the plugin able to do traceroute. For now I'm doing it on Windows7. Currently I chose to use Win32API CreateProcess to call the command shell. By setting dwFlags = STARTF_USESHOWWINDOW , I'm able to hide the command shell window during execution.
PROBLEM : The createProcess is implemented in a method called run() where I called it using JS for testing. When I called plugin().run(), the traceroute is working well, and the output was succesfully written in a textfile as I wanted. However during the execution, the browser become unresponsive and lastly the plugin crashed seconds after the traceroute completed. As I am new to plugin development and only have a little knowledge on c++ , I wonder why this problem arisen. FYI, if I did not hide the commandshell window, the plugin worked wonder - the browser was responsive while the traceroute was executed.
It is very important in any NPAPI plugin (with FireBreath or otherwise) that you don't block the main (the javascript) thread. What you're trying to do could be done in a couple of ways; I'd probably pass in a callback, start a new thread, do the createprocess there, and then fire the js callback when it completes with the result.
See FireBreath Tips: Asynchronous Javascript Calls.
The one thing to watch out for is you need to be able to terminate the thread (and the process) if the plugin is shut down during the call.
I want to make some debug console for my application. It should output some data and take input commands. How can I do this? The best way is updating console like: drawing information and prompt for input after the data.
I'm developing under Linux. For example, gdb could take input from console.
If you're familiar with socket programming (or actually, any other kind of IPC mechanism), you might want to enable some listener within your application, and develop an external application that will do all the "console" stuff for you, while communicating with the main application.
Let's suppose you have an application that has a single button and a single text label, and every time you press that button - the text label goes up by 1, from 1 to 2 to 3 etc.
You can build a socket listener into that application. When the socket listener accepts a new incoming connection, you'd start a connection thread that can:
Receive a "shutdown" command
Receive a "reset counter" command
Send an update regarding the current count on every click
etc.
Then you build another, external application, which connects to the main application, and sends messages to it, based on console input it gets from the user. It would also listen to incoming updates and show them to the user.
Using an external application for debug-controlling your main application is extremely helpful, with the following reasons being some of the advantages:
No matter how the debug application is buggy, it cannot hurt the release version of your main application.
All the code that deals with the console management, which is redundant to your main application, can be kept outside of the main app.
Making two projects out of it can make it easier to collaborate your work with someone else, as long as you are both aware of the protocol between the two sides.
Implementing what I suggested means you can debug your application remotely, in case you don't have access to the main application (for example, if it's on a customer site).
How can i programatically check if the windows shell (explorer) has loaded all startup programs & the user login process is over ?
There is a somewhat documented event you can wait for, but it is signaled when explorer has started loading. On XP this event is called "msgina: ShellReadyEvent" and "ShellDesktopSwitchEvent" on Vista. I linked to the sources of some alternative shells in a post related to this event.
Another alternative would be to listen for the Taskbar Creation Notification message. It can fire more than once so you would need to keep track of that.
On Vista+ there is one last alternative that might just work: Programs set to run at startup are part of a job object so they cannot run at high priority. If your program runs at startup you could maybe check for this, either by using IsProcessInJob or SetPriorityClass+GetPriorityClass in a loop. (SetPriorityClass will lie about its return value IIRC)