In my App I have an annoying behavior. It is causing problems to my costumers.
The app has several points where I need to show a Dialog (Modal), then the users can fill some fields and then they can close the dialog. So the system follows its natural path.
In determined moments this works fine. The dialog is shown, user interacts with it, closes it , ....
But, in others moments (the same code) the dialog doesn't appear automatically. The user needs to execute some external action on device (like change its orientation, touch in the center of the screen, execute scroll gesture, etc). Some action that isn't intuitive at the moment.
This behavior makes the user think my app froze.
For me it is clear that the dialog was called, simply it wasn't drawed on the screen.
I tryed read about this problem.I did some researches in similar questions without success.
I guess the cause is related to EDT.
In short, How can I call a Dialog Modal without breaking EDT-rules.
And more specifically, How can I resolve this problem.
when I request a dialog to be displayed on the screen, I want it really appears in 100% of cases. Today works randomly.
Additional infomations:
My app uses Java 5 yet.
Do you recommends migration to Java 8?
======= Additional Informations (1) ===========
This problem is strongly dependent of device model.
In MotoG3 (Android 6) this problem is a exception. Rarely it occurs.
In my Galaxy Note 8 is the opposite. Always occurs.
In Lenovo Vibe5 (Android 6). Frequently occurs.
I added these informations. Maybe it help to compound problem picture.
Additional question:
Is it possible write a snippet that I can use as a template
to execute Dialog Modal call without break some rule of EDT?
Turn on the EDT violation detection tool in the simulator which should detect such issues. Inspect potentially problematic cases of Dialog calls and post them specifically if you don't know how to fix them.
Java 8 is unrelated although migrating a project is non-trivial.
Related
Context:
Reading some GUI libraries on Linux 64.
I've always used libraries (or done headless applications). Now, it is time to move on and complete my understanding.
Question:
I am not sure how the system knows when one clicks a button on a gui app.
It seems that poll/select/epoll helps but I don't get the whole picture.
Here is what I think:
When the gui is created, it knows where the buttons pixels are, so it attaches each of them to an event handler (epoll...), OR just one callback to react to a click in this app.
When I click a button, epoll calls the callback for this application which manages the click events. the callback iterates the list to find the button.
Of course, there are optimisations, like dividing the screen in multiple squares for example and many other things.
But, am I correct ? is this the logic under the hood ? Is X11 more involved ?
Thanks
Ok, after your comment: I'll bite:
No, you are not right.
But how does that increase your knowledge now?
TL;DR:
application is built with WPF, running on .Net 3.5
newest and older versions of the app work properly on many different machines
on one specific machine it malfunctions in a strange way:
either does not start, displays black screen instead of "welcome" screen; can't do anything on that black screen
or does start and works properly, until a TextBox is presented and until the user starts entering the text into it; then application immediatelly hangs
Background:
I have built a WPF application on .Net 3.5. I've checked the application on various machines with different OS, ranging from Windows XP up to Windows 7 - and it runs fine, no bugs, etc. It also works fine on my client's several target machines, XP and W7 included again.
However, on one machine, it suddenly ceased to work. My client sent me the machine so I can investigate. From the files on its drives, I can see there were older versions, and they were used by the client for a few months. I also see that the newest version is not installed yet on this machine. So, I tried running the old versions first, to see what's the problem.
What user sees:
oldest versions (say, v1, v2) of the application does not work at all. When they start up, the only thing the application displays is ... absolutely completely black window. There should be a "welcome" screen, composed of few images and labels and a button. The app is not frozen it is "responsive" (Win7 can communicate with it, the window is not dimmed).
last (but not newest, let's name it v3) application runs fine, everything is clickable, features work OK, except one. When user is asked to provide a password, the user is presented with single TextBox in a popup. When the user enters at least one character in that textbox, the application freezes. It freezes even before having rendered the masked '*' of the password. The freezing is total, the application stops responding (the window is dimmed and the OS wants to close it), CPU goes to 100% (actually 50%, two-core system) and the only way to stop is kill it via task manager.
then I installed and tried running the newest version (v4) - it behaves just like v3 above
I've also tried reinstalling all the versions, just to be ensure the .EXE/.DLL files are not damaged - no changes (v1/2 - black, v3/4 - freeze on text)
Technical bits, just FYI:
The app is very simple, one executable with no shared libraries and no shared configuration. There is just no way the newest version could interact with old versions. Seriously, I intentionally made the app in a way it can be "just copied" and several instances can be safely kept in separate folders.
All versions of the app (v4, v3, v2, v1) work properly on all other machines, with various versions of Windows
The problem can't be related to user files or configuration, I tried copying them from problematic machine to healthy ones, and the problem does not repeat
Related to password box: There are absolutely no event handlers in the code that could produce a deadlock or freezing. The password textbox has no text-changed handlers. My code reads the text only after an "OK" button is pressed. The app freezes immediatelly when user enters first character, the
user does not even get a chance to press "OK"
Related to startup: The app does almost nothing on startup. It merely displays some form of a splash/welcome screen. There is no logic there except for a nice UI and one button. The user has no chance of pressing that button. When the app starts, the screen is black and has no contents, not even the splash/welcome image.
Tracing and observations:
I've focused on the TextBox part, since it's more granular.
I've got the app to freeze again, and checked the threads with ProcessHacker.
Except for typical threads, one thread that was sitting and busy-spinning at:
wpfgfx_v0300.dll MilGlyphRun SetGeometryAtRenderTime
wpfgfx_v0300.dll MilGlyphRun SetGeometryAtRenderTime
...
wpfgfx_v0300.dll MilContent DetachFromHWND
That's certainly problem with the WPF layer itself. The DetachFromHWND tells me close to nothing, but MilGlyphRun is surely about the text rendering. It freezes while trying to render the text. I've checked the black-screens on older versions of the applications, but I couldn't catch it, since the apps were not frozen, just black.
So..
I've applied literally all pending updates (like, 150 of them, ~800 Mb, most of them were to the OS and .Net framework)
I've tried reinstalling all video drivers
No changes, still black screen, still freezing.
So, focusing back to the problem. It failed to render a text. Sounds obvious, since it deadlocked when user entered a character into a textbox, but it's damn not obvious! The user was presented with tons of different TextBoxes until he finally got to the PasswordBox. All TextBoxes worked OK, only this one fails. And why old verions of the app display black screen and the new version displays the "welcome" screen properly? How can be those issues related?
The connection is: Windows Presentation Foundation Font Cache service.
Sources:
http://support.microsoft.com/kb/937135
http://social.msdn.microsoft.com/Forums/vstudio/en-US/7cc032c1-5f4d-4518-adc6-f53afd051e6b/presentationhostexe-running-at-50-cpu?forum=wpf
WPF uses a Font-Cache service, running as a separate process, for, well, caching fonts. Whenever your WPF app needs to draw some text, it might ask the cache service for fonts. Once in a while the font cache might get corrupted and it then will/may randomly impact any WPF application.
Unfortunatelly, restarting the service is not enough. When this happens, you must delete all FontCache files that this service keeps on the disk. Before deleting them, you must stop the "Windows Presentation Foundation Font Cache service (or whatever it's called in your languge, for example Usługa buforowania czcionek platformy Windows Presentation Foundation in Polish..). Then, go to
Win7: %systemdrive%\Windows\ServiceProfiles\LocalService\AppData\Local\
Vista: %systemdrive%\Windows\ServiceProfiles\LocalService\AppData\Local\
WinXP: %systemdrive%\Documents and Settings\LocalService\Local Settings\Application Data
and remove all files looking like FontCache.dat. The source articles mentioned only one file (FontCache3.0.0.0.dat, but in my case there were around 8 files with similar naming convention).
After deleing them and restarting the service, all versions of my application were running properly again. No black screens, no freezing on textbox.
I am working at an OS independent file manager (using SDL). I am trying to use native functions as much as possible (with the appropriate #ifdefs), and I am having a problem with Windows. When I am using
CopyFileEx()
for example, if there is a problem it will pop up a modal dialogue, and the user will have to press some buttons to get rid of it. I want to handle the errors myself, in my programs, to make it less annoying.
Is there any way to disable those modal windows?
I noticed that if I start my application from a debugger (Insight) it will not display those messages.
Thanks in advance!
P.S. The language I am using is plain C.
You might want the SetErrorMode function.
For a Windows file manager SHFileOperation() is possible a better fit than CopyFileEx(). This will result in the native sheall dialogs for progress, conflict resolution etc. The levels of progress and error reporting can all be controlled.
I've been working on this problem on and off for about a month. I don't expect anybody to be able to give me a definitive answer. I'm just completely out of ideas at this point and could use anything.
The problem is that my app crashes on only some models of phones. I have an HTC surround and it runs fine. It has also been tested on a Samsung Focus and it works there to. It crashes pretty consistently on a HTC mozart. There are other phones it crashes on but I don't know what models they are. I don't have access to an HTC mozart so debugging has been very difficult.
I'm handling the application UnhandledException event and I have try catch around every background thread. The error handling code never runs.
What I know:
Sometimes it freezes and requires a press of the power button. At least once it required the battery taken out. Most of the time it freezes and then crashes.
Most of the time it crashes on the main menu, before everything displays.
It's not 100% consistent. Sometimes it works for a little bit, but never very long.
It's not because it's out of memory. Most of the time it crashes while using less then 8MB.
When all the exception handling didn't work I added debug logging. This slows things way down but at the same time the issue goes away.
These symptoms make it sound like a deadlock to me. Although I have gone over the code and there is no thread ever entering more then 1 lock at a time.
Any ideas on how I should track this down would be appreciated.
Edit: This is a WP7 version of my game. I've just been able to confirm with a volunteer with an HTC mozart that the simplest conversion of the code meant for to run on the web will crash on the phone. That's code has no networking, isolated storage, or sound.
I also should have mentioned that this has passed certification and was in the marketplace for a few days until I took it down because it got bad reviews (because it was unplayable for some people)
If the devices are locking up, then my suspicions would be to look at the areas where you are closest to the driver level/hardware, which (looking at your game) are:
the display
the sound
It could also be just about due to processing/CPU activity - but generally "User level" code shouldn't be able to lock up your phone - that functionality is reserved for kernel software.
The only way of really testing this is to get hold of a device where this "reliably crashes" (e.g. a Mozart) and to go through the process of disabling bits of functionality one by one.
If this is a Silverlight app, then I'd expect Microsoft to want to help - I'd contact them via AppHub and via their local Evangelist team - they'll have the means and the motivation to assist you.
I'm happy to assist on testing on a developer-unlocked HTC Trophy if that helps!
The only thing I can think of that's unique to the Mozart is that it has an 8MP camera and all others have a 5MP camera.
Are you using a CameraCaptureTask and expecting the returned image to be a certain size?
Other than that, what does the app do? what services and device functionality are you using?
Do you have any network access running on a background thread?
I had roughly the same problem when developing my WP7 app. As far as I can tell it isn't as much model bound as it is device bound. In fact I had my app deployed to 15+ Trophy's (my company gave all their employees one of those) and it would repeatedly crash on some of them all having the same firmware. Some of the feedback I got through the reviews seems to indicate that it also happens in the wild.
In my case the crash occurs primarily (only?) when the app is launched. There does seem to be a strong correlation between internet connectivity and crashing in that I can 'recreate' the crash by putting my phone in flight mode, unplugging the network cable from my computer and then deploying the app. In that case too it immediately crashes and no event or break point is ever raised.
My gut feeling tell me it might have something to do with the map control as that does tend to respond funky to poor connectivity when the application is loading (like displaying an error message that the card cant be loaded while simultaneously displaying the map)
Does your app also use the Map Control (in combination with a Pivot control perhaps?)
Some of the devices have issues where you need set things to "content" instead of "embedded resource" in your project.
Although i've more heard about that issue related to app startup time, as on some devices (HD7?) the load of the app was taking enough time that the app was never allowed to start, the OS thought it was taking too long and killed it.
Edit: In addition to the bounty, we're willing to pay $250 to have this bug fixed in the Firefox/Gecko codebase. Here is a simple test project (Visual Studio 2008 C#) that reproduces the problem.
Edit #2 we're willing to pay $600 to have this bug fixed. See above for sample project that reproduces the problem.
We have a Firefox (Gecko) ActiveX control on our C# Windows Form to display HTML.
When this Firefox ActiveX control is on our form, about 2-3% of our key presses don't make it through. Or rather, a different Windows message is sent:
We hold down the TAB key to tab through 3 regular WinForms text boxes. It will behave correctly 97% of the time. Spy++ tells us WM_KEYDOWN message is sent properly:
normal behavior http://judahhimango.com/images/normaltab.jpg
But randomly, maybe 2-3% of the time, the tab key (or other key) isn't processed right. Spy++ tells us WM_CHAR is being sent instead:
odd behavior http://judahhimango.com/images/screwytab.png
When the odd behavior occurs, either the key is not processed at all, or is processed incorrectly (such as inserting a '\t' character into a textbox that doesn't support tab characters.
This only occurs if the Firefox ActiveX control is on our form.
Our question is: does Firefox/Gecko engine install some kind of keyboard hook that might cause these side effects? Or better yet, how do we fix this problem?
The WM_CHAR message is generated by TranslateMessage call, so a good place to start looking would be the TranslateMessage calls in the Gecko source code.
In the first example code you provided the function is imported only by two libraries - mozctl.dll and xul.dll. Since you claim that the same error happens also with GeckoFX we can take mozctl.dll out of the equation. That leaves us with xul.dll, so given the Gecko source code I would suggest to look into widget\src\windows\nsToolkit.cpp. I am not sure if the code is run if the engine is embedded, but if it is then the library starts a whole new message pump in different thread, which is bound to break.
Unfortunately I can't run or compile the code on my machine (Windows 7 x64 w/o the Mozilla ActiveX control installed), so I can't verify any of this with a debugger. Hope it helps someone to track it down further.
The root problem is that when Mozilla is embedded in another application, it incorrectly pumps Windows messages when it dispatches internal events. Mozilla uses an event system to coordinate across threads or to schedule deferred processing on a thread (see nsIThread, nsIEventTarget). If you embed a web page with a lot of active XMLHTTPRequests, for example, Mozilla will use its event dispatching interface to dispatch events back to javascript and it will pump windows messages as a side effect. Once Mozilla events are fully dispatched, it goes back to the main event loop.
When Mozilla pumps windows messages, it doesn't include the extra processing done by the application's event loop - IsDialogMessage(), TranslateMessage(), PreTranslateMessage(), or any other pre-processing are skipped when Mozilla gets into this state. Symptoms therefore include tab key presses getting inserted as a character instead of being used for dialog navigation, keyboard hotkeys being sporadically ignored, or custom message pre-processing being sporadically skipped. For example, the Outlook 2007/2010 "Compose" screen sporadically loses keystrokes because it relies on custom message pre-processing to handle keyboard input.
See https://bugzilla.mozilla.org/show_bug.cgi?id=582790 for a patch that addresses the problem.
I have Snoop Free and PSM Anti-Keylogger.
One of them detected firefox trying to install a Keyboard Hook.
Mozilla/Firefox file xul.dll attempt at installing at keyboard hook.
DENIED.
I noticed that you have implemented all of the interoperability yourself. Can you try this with the GeckoFX project and see if you get the same error? I use this project at work and haven't encountered any issues yet.