Bug 440300 - Embedded IE compatibility mode not updated in Registry, after forceful termination of an SWT application(with embedded IE)
Summary: Embedded IE compatibility mode not updated in Registry, after forceful termin...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Target Milestone: 4.4.1   Edit
Assignee: Niraj Modi CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 422056 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-07-24 04:44 EDT by Niraj Modi CLA
Modified: 2016-02-24 10:48 EST (History)
5 users (show)

See Also:
arunkumar.thondapu: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Niraj Modi CLA 2014-07-24 04:44:57 EDT
Issue reported @ https://bugs.eclipse.org/bugs/show_bug.cgi?id=404543#c5

The cause was an earlier run of SWT not clearing out one of its browser related registry entries on exit, but since it was almost certainly caused by a crash or forced program termination I'm not sure that it can be classified as an SWT bug. When this occurs though it permanently prevents changing the IE compatibility mode via command line or directly setting the system property  org.eclipse.swt.browser.IEVersion.


To replicate the issue:
-----------------------

1. Regular Windows 7 installation, having any version of IE installed. Other versions of Windows will probably also be affected.

2. Start a bare bones Java program with embedded SWT browser, using the command line to force the IE into an earlier compatibility mode, eg. -Dorg.eclipse.swt.browser.IEVersion=9000.

3. Verify the IE user agent to ensure that the compatibility mode has been set.

4. SWT will check for a registry key to set the embedded IE compatibility mode for the Java process, adding it only if it's not already there. The key is HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\<java process name>.

5. Force the Java program to terminate abruptly so that SWT doesn't have a chance to remove the temporary key.

6. Re-run the Java program, this time either without the command line option altogether or try to force a different IE compatibility mode than that set in step 2.

7. Again check the IE user agent string, which will now be stuck at the compatibility mode from step 2.


Workaround:
-----------

Delete the registry key at HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\<java process name>, eg. java.exe


Cause:
------

The problem is caused by an abrupt termination of any Java program that embeds an SWT browser in IE mode.


Code reference:
---------------
SWT's browser/IE.java, specifically the initialiser code within the create() method.

This code checks for a registry key entry for the current Java process to ensure the IE compatibility mode. If there's none present it adds the key and registers a Display dispose listener to clean up the key when SWT has finished. The critical issue is that if the key is already there, no changes are made, and the existing entry will be used no matter what IE compatibility mode has been specified elsewhere. Leaving the registry key as-is rather than obliterating it is probably the right thing to do though.

I hope that helps anyone else that comes across this problem.
Comment 1 Niraj Modi CLA 2014-07-24 09:00:27 EDT
During IE#create(), program name & IE version entry is added to the Windows registry and same gets deleted during the dispose cycle.
Since there is a possibility of the entry not getting deleted, if the SWT application crashes or is exited forcefully.

Proposed solution: Not only just create a new registry entry for Program name and IE version pair, but also update it with the new IE version when such entry already exists in the registry during IE#create. And the same gets deleted from the registry on proper application dispose.
Comment 3 Nobody - feel free to take it CLA 2014-07-29 07:00:06 EDT
Thank you, Niraj.
Comment 4 Niraj Modi CLA 2014-08-05 08:42:46 EDT
Verified the fix in I20140804-2000 build.
Comment 5 Niraj Modi CLA 2014-08-06 05:35:00 EDT
Reopening this bug for back-port to 4.4.1 release.
Arun, for your review.
Comment 6 Arun Thondapu CLA 2014-08-06 07:20:23 EDT
(In reply to Niraj Modi from comment #5)
> Reopening this bug for back-port to 4.4.1 release.
> Arun, for your review.

Approved for back port to 4.4.1.
Comment 7 Niraj Modi CLA 2014-08-06 07:46:06 EDT
Thanks for the quick review Arun.
Back-ported the change to 'R4_4_maintenance' branch via below patch:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?h=R4_4_maintenance&id=944405bda7af034dbc2cb634b07677d56d54280a
Comment 8 Niraj Modi CLA 2014-08-28 06:10:06 EDT
Verified the fix in M20140827-1200 build
Comment 9 Arun Thondapu CLA 2014-11-03 06:29:18 EST
*** Bug 422056 has been marked as a duplicate of this bug. ***