JDK-8130136 : Swing window sometimes fails to repaint partially when it becomes exposed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u26
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-06-30
  • Updated: 2019-11-29
  • Resolved: 2015-10-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 JDK 8 JDK 9
6u111Fixed 7u101Fixed 8u72Fixed 9 b92Fixed
Related Reports
Relates :  
Relates :  
Description
Sometimes a window fails to repaint when it becomes exposed.

Further analysis shows the following. When repaint failure occurs, SetDIBitsToDevice() in GDIBlitLoops_nativeBlit() returns 0 with error 87 ("Parameter Error"). This error usually means that the device context passed as the first parameter to SetDIBitsToDevice is invalid, for example this device context handle was released already.
Comments
Detailed root cause analysis. The log contained additional prints added to AWT native code. 1. EDT needs to paint hWnd = 0x007b085c @@@ GDIBlitLoops_nativeBlit begin @@@ Current Time: 2015-10-08T13:23:16.824 @@@ Current Thread ID: 0x00000308 @@@ SetupThreadGraphicsInfo(JNIEnv *env, GDIWinSDOps *wsdo = 0x53db6400) @@@ 0x00000308 = GetCurrentThreadId() @@@ if( ((oldhDC == NULL) && wsdo->window != NULL) || @@@ (info->wsdo != wsdo) || @@@ (info->wsdoTimeStamp != wsdo->timeStamp) ) @@@ ==> oldhDC = 0xe601190d, wsdo->window = 0x007b085c, info->wsdo = 0x5859bfb8, wsdo = 0x53db6400, info->wsdoTimeStamp = 33710, wsdo->timeStamp = 26 @@@ AwtComponent::MoveDCToPassiveList(HDC hDC = 0xe601190d) @@@ 0x590a4f70 = activeDCList.RemoveDC(hDC = 0xe601190d), hWnd = 0x04c7026a @@@ passiveDCList.AddDCItem(removedDC = 0x590a4f70) @@@ Moved DC to passive list: hDC = 0xe601190d, wsdo = 0x53db6400, hWnd = 0x007b085c @@@ 0x54aad2f8 = GDIWindowSurfaceData_GetComp(env, wsdo = 0x53db6400) @@@ calling comp->GetDCFromComponent() @@@ AwtComponent::GetDCFromComponent() @@@ calling SendMessage(WM_AWT_GETDC) @@@ WM_AWT_GETDC @@@ Current Time: 2015-10-08T13:23:16.840 @@@ Current Thread ID: 0x00000e18 @@@ AwtComponent::ReleaseDCList(HWND hwnd = 0x007b085c, DCList &list) @@@ ::ReleaseDC(tmpDCList->hWnd = 0x007b085c, tmpDCList->hDC = 0x2e010407) @@@ AwtGDIObject::Decrement(): numCurrentObjects = 2 / maxGDIObjects = 9000 @@@ AwtGDIObject::IncrementIfAvailable(): numCurrentObjects = 3 / maxGDIObjects = 9000 @@@ 0x2e010407 = ::GetDCEx(GetHWnd() = 0x007b085c, NULL, DCX_CACHE | DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS) @@@ activeDCList.AddDC(hDC = 0x2e010407, GetHWnd() = 0x007b085c) @@@ AwtComponent::GetDCFromComponent() returns hdc = 0x2e010407 @@@ 0x2e010407 = comp->GetDCFromComponent() @@@ 25 = SetDIBitsToDevice(hDC = 0x2e010407, XDest = 15, YDest = 115, dwWidth = 59, dwHeight = 25, XSrc = 0, YSrc = 0, uStartScan = 0, cScanLines = 25, lpvBits = 0x1e2eda64, lpbmi = 0x544ae4c0, fuColorUse = 0) @@@ GDIBlitLoops_nativeBlit end The cached hDC = 0xe601190d is moved to passive list, and new hDC = 0x2e010407 is acquired for hWnd = 0x007b085c. 2. EDT needs to paint hWnd = 0x04c7026a @@@ GDIBlitLoops_nativeBlit begin @@@ Current Time: 2015-10-08T13:23:16.871 @@@ Current Thread ID: 0x00000308 @@@ SetupThreadGraphicsInfo(JNIEnv *env, GDIWinSDOps *wsdo = 0x5859bfb8) @@@ 0x00000308 = GetCurrentThreadId() @@@ if( ((oldhDC == NULL) && wsdo->window != NULL) || @@@ (info->wsdo != wsdo) || @@@ (info->wsdoTimeStamp != wsdo->timeStamp) ) @@@ ==> oldhDC = 0x2e010407, wsdo->window = 0x04c7026a, info->wsdo = 0x53db6400, wsdo = 0x5859bfb8, info->wsdoTimeStamp = 26, wsdo->timeStamp = 33710 @@@ AwtComponent::MoveDCToPassiveList(HDC hDC = 0x2e010407) @@@ 0x590a4ee0 = activeDCList.RemoveDC(hDC = 0x2e010407), hWnd = 0x007b085c @@@ passiveDCList.AddDCItem(removedDC = 0x590a4ee0) @@@ Moved DC to passive list: hDC = 0x2e010407, wsdo = 0x5859bfb8, hWnd = 0x04c7026a @@@ 0x53d13b38 = GDIWindowSurfaceData_GetComp(env, wsdo = 0x5859bfb8) @@@ calling comp->GetDCFromComponent() @@@ AwtComponent::GetDCFromComponent() @@@ calling SendMessage(WM_AWT_GETDC) @@@ WM_AWT_GETDC @@@ Current Time: 2015-10-08T13:23:16.871 @@@ Current Thread ID: 0x00000e18 @@@ AwtComponent::ReleaseDCList(HWND hwnd = 0x04c7026a, DCList &list) @@@ ::ReleaseDC(tmpDCList->hWnd = 0x04c7026a, tmpDCList->hDC = 0xe601190d) @@@ AwtGDIObject::Decrement(): numCurrentObjects = 2 / maxGDIObjects = 9000 @@@ AwtGDIObject::IncrementIfAvailable(): numCurrentObjects = 3 / maxGDIObjects = 9000 @@@ 0xe601190d = ::GetDCEx(GetHWnd() = 0x04c7026a, NULL, DCX_CACHE | DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS) @@@ activeDCList.AddDC(hDC = 0xe601190d, GetHWnd() = 0x04c7026a) @@@ AwtComponent::GetDCFromComponent() returns hdc = 0xe601190d @@@ 0xe601190d = comp->GetDCFromComponent() @@@ 25 = SetDIBitsToDevice(hDC = 0xe601190d, XDest = 188, YDest = 1021, dwWidth = 85, dwHeight = 25, XSrc = 0, YSrc = 0, uStartScan = 0, cScanLines = 25, lpvBits = 0x09a57fb0, lpbmi = 0x544ae4c0, fuColorUse = 0) @@@ GDIBlitLoops_nativeBlit end The cached hDC = 0x2e010407 (of hWnd = 0x007b085c) is moved to passive list. ... 3. Now EDT needs to paint hWnd = 0x007b085c again @@@ GDIBlitLoops_nativeBlit begin @@@ Current Time: 2015-10-08T13:23:16.918 @@@ Current Thread ID: 0x00000308 @@@ SetupThreadGraphicsInfo(JNIEnv *env, GDIWinSDOps *wsdo = 0x53db6400) @@@ 0x00000308 = GetCurrentThreadId() @@@ if( ((oldhDC == NULL) && wsdo->window != NULL) || @@@ (info->wsdo != wsdo) || @@@ (info->wsdoTimeStamp != wsdo->timeStamp) ) @@@ ==> oldhDC = 0xe601190d, wsdo->window = 0x007b085c, info->wsdo = 0x5859bfb8, wsdo = 0x53db6400, info->wsdoTimeStamp = 33710, wsdo->timeStamp = 26 @@@ AwtComponent::MoveDCToPassiveList(HDC hDC = 0xe601190d) @@@ 0x590a4f70 = activeDCList.RemoveDC(hDC = 0xe601190d), hWnd = 0x04c7026a @@@ passiveDCList.AddDCItem(removedDC = 0x590a4f70) @@@ Moved DC to passive list: hDC = 0xe601190d, wsdo = 0x53db6400, hWnd = 0x007b085c @@@ 0x54aad2f8 = GDIWindowSurfaceData_GetComp(env, wsdo = 0x53db6400) @@@ calling comp->GetDCFromComponent() @@@ AwtComponent::GetDCFromComponent() @@@ calling SendMessage(WM_AWT_GETDC) @@@ WM_AWT_GETDC @@@ Current Time: 2015-10-08T13:23:16.918 @@@ Current Thread ID: 0x00000e18 @@@ AwtComponent::ReleaseDCList(HWND hwnd = 0x007b085c, DCList &list) @@@ ::ReleaseDC(tmpDCList->hWnd = 0x007b085c, tmpDCList->hDC = 0x2e010407) @@@ AwtGDIObject::Decrement(): numCurrentObjects = 2 / maxGDIObjects = 9000 @@@ AwtGDIObject::IncrementIfAvailable(): numCurrentObjects = 3 / maxGDIObjects = 9000 @@@ 0x2e010407 = ::GetDCEx(GetHWnd() = 0x007b085c, NULL, DCX_CACHE | DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS) @@@ activeDCList.AddDC(hDC = 0x2e010407, GetHWnd() = 0x007b085c) @@@ AwtComponent::GetDCFromComponent() returns hdc = 0x2e010407 @@@ 0x2e010407 = comp->GetDCFromComponent() @@@ 25 = SetDIBitsToDevice(hDC = 0x2e010407, XDest = 15, YDest = 115, dwWidth = 59, dwHeight = 25, XSrc = 0, YSrc = 0, uStartScan = 0, cScanLines = 25, lpvBits = 0x1e2eda64, lpbmi = 0x544ae4c0, fuColorUse = 0) @@@ GDIBlitLoops_nativeBlit end The handle to DC 0x2e010407 is released from the passive list (it was put to passive list at step 2). And GetDCEx(hWnd = 0x007b085c) returns the same handle 0x2e010407. 4. Another hWnd = 0x04c7026a is about to be painted on EDT @@@ GDIBlitLoops_nativeBlit begin @@@ Current Time: 2015-10-08T13:23:21.239 @@@ Current Thread ID: 0x00000308 @@@ SetupThreadGraphicsInfo(JNIEnv *env, GDIWinSDOps *wsdo = 0x5859bfb8) @@@ 0x00000308 = GetCurrentThreadId() @@@ if( ((oldhDC == NULL) && wsdo->window != NULL) || @@@ (info->wsdo != wsdo) || @@@ (info->wsdoTimeStamp != wsdo->timeStamp) ) @@@ ==> oldhDC = 0x2e010407, wsdo->window = 0x04c7026a, info->wsdo = 0x53db6400, wsdo = 0x5859bfb8, info->wsdoTimeStamp = 26, wsdo->timeStamp = 33710 @@@ AwtComponent::MoveDCToPassiveList(HDC hDC = 0x2e010407) @@@ 0x590a4ee0 = activeDCList.RemoveDC(hDC = 0x2e010407), hWnd = 0x007b085c @@@ passiveDCList.AddDCItem(removedDC = 0x590a4ee0) @@@ Moved DC to passive list: hDC = 0x2e010407, wsdo = 0x5859bfb8, hWnd = 0x04c7026a @@@ 0x53d13b38 = GDIWindowSurfaceData_GetComp(env, wsdo = 0x5859bfb8) @@@ calling comp->GetDCFromComponent() @@@ AwtComponent::GetDCFromComponent() @@@ calling SendMessage(WM_AWT_GETDC) @@@ WM_AWT_GETDC @@@ Current Time: 2015-10-08T13:23:21.239 @@@ Current Thread ID: 0x00000e18 @@@ AwtComponent::ReleaseDCList(HWND hwnd = 0x04c7026a, DCList &list) @@@ ::ReleaseDC(tmpDCList->hWnd = 0x04c7026a, tmpDCList->hDC = 0xe601190d) @@@ AwtGDIObject::Decrement(): numCurrentObjects = 2 / maxGDIObjects = 9000 @@@ AwtGDIObject::IncrementIfAvailable(): numCurrentObjects = 3 / maxGDIObjects = 9000 @@@ 0xc501159b = ::GetDCEx(GetHWnd() = 0x04c7026a, NULL, DCX_CACHE | DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS) @@@ activeDCList.AddDC(hDC = 0xc501159b, GetHWnd() = 0x04c7026a) @@@ AwtComponent::GetDCFromComponent() returns hdc = 0xc501159b @@@ 0xc501159b = comp->GetDCFromComponent() @@@ 23 = SetDIBitsToDevice(hDC = 0xc501159b, XDest = 3, YDest = 25, dwWidth = 1594, dwHeight = 23, XSrc = 0, YSrc = 0, uStartScan = 0, cScanLines = 23, lpvBits = 0x0944962c, lpbmi = 0x544ae4c0, fuColorUse = 0) @@@ GDIBlitLoops_nativeBlit end The handle hDC = 0x2e010407 we are watching is moved to passive list. 5. Toolkit thread needs to paint hWnd = 0x007b085c @@@ GDIBlitLoops_nativeBlit begin @@@ Current Time: 2015-10-08T13:23:22.222 @@@ Current Thread ID: 0x00000e18 @@@ SetupThreadGraphicsInfo(JNIEnv *env, GDIWinSDOps *wsdo = 0x53db6400) @@@ 0x00000e18 = GetCurrentThreadId() @@@ if( ((oldhDC == NULL) && wsdo->window != NULL) || @@@ (info->wsdo != wsdo) || @@@ (info->wsdoTimeStamp != wsdo->timeStamp) ) @@@ ==> oldhDC = 0x2e010407, wsdo->window = 0x007b085c, info->wsdo = 0x53db6400, wsdo = 0x53db6400, info->wsdoTimeStamp = 26, wsdo->timeStamp = 26 @@@ 1142 = SetDIBitsToDevice(hDC = 0x2e010407, XDest = 3, YDest = 25, dwWidth = 1594, dwHeight = 1142, XSrc = 0, YSrc = 0, uStartScan = 0, cScanLines = 1142, lpvBits = 0x1e2618a4, lpbmi = 0x541de810, fuColorUse = 0) @@@ GDIBlitLoops_nativeBlit end It successfully paints the window 0x007b085c with its cached hDC = 0x2e010407. However, this hDC = 0x2e010407 is already in the passive list. 6. EDT needs to paint hWnd = 0x007b085c, the window of interest @@@ GDIBlitLoops_nativeBlit begin @@@ Current Time: 2015-10-08T13:23:22.238 @@@ Current Thread ID: 0x00000308 @@@ SetupThreadGraphicsInfo(JNIEnv *env, GDIWinSDOps *wsdo = 0x53db6400) @@@ 0x00000308 = GetCurrentThreadId() @@@ if( ((oldhDC == NULL) && wsdo->window != NULL) || @@@ (info->wsdo != wsdo) || @@@ (info->wsdoTimeStamp != wsdo->timeStamp) ) @@@ ==> oldhDC = 0xc501159b, wsdo->window = 0x007b085c, info->wsdo = 0x5859bfb8, wsdo = 0x53db6400, info->wsdoTimeStamp = 33710, wsdo->timeStamp = 26 @@@ AwtComponent::MoveDCToPassiveList(HDC hDC = 0xc501159b) @@@ Moved DC to passive list: hDC = 0xc501159b, wsdo = 0x53db6400, hWnd = 0x007b085c @@@ 0x54aad2f8 = GDIWindowSurfaceData_GetComp(env, wsdo = 0x53db6400) @@@ calling comp->GetDCFromComponent() @@@ AwtComponent::GetDCFromComponent() @@@ calling SendMessage(WM_AWT_GETDC) @@@ WM_AWT_GETDC @@@ Current Time: 2015-10-08T13:23:22.238 @@@ Current Thread ID: 0x00000e18 @@@ AwtComponent::ReleaseDCList(HWND hwnd = 0x007b085c, DCList &list) @@@ ::ReleaseDC(tmpDCList->hWnd = 0x007b085c, tmpDCList->hDC = 0x2e010407) @@@ AwtGDIObject::Decrement(): numCurrentObjects = 1 / maxGDIObjects = 9000 @@@ AwtGDIObject::IncrementIfAvailable(): numCurrentObjects = 2 / maxGDIObjects = 9000 @@@ 0xee0121b1 = ::GetDCEx(GetHWnd() = 0x007b085c, NULL, DCX_CACHE | DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS) @@@ activeDCList.AddDC(hDC = 0xee0121b1, GetHWnd() = 0x007b085c) @@@ AwtComponent::GetDCFromComponent() returns hdc = 0xee0121b1 @@@ 0xee0121b1 = comp->GetDCFromComponent() @@@ 59 = SetDIBitsToDevice(hDC = 0xee0121b1, XDest = 10, YDest = 334, dwWidth = 1562, dwHeight = 59, XSrc = 0, YSrc = 0, uStartScan = 0, cScanLines = 59, lpvBits = 0x1e4428c8, lpbmi = 0x544ae4c0, fuColorUse = 0) @@@ GDIBlitLoops_nativeBlit end Here hDC = 0x2e010407 that was put to passive list at step 4 gets released. 7. Here it is! EDT needs to paint hWnd = 0x007b085c @@@ GDIBlitLoops_nativeBlit begin @@@ Current Time: 2015-10-08T13:23:28.649 @@@ Current Thread ID: 0x00000e18 @@@ SetupThreadGraphicsInfo(JNIEnv *env, GDIWinSDOps *wsdo = 0x53db6400) @@@ 0x00000e18 = GetCurrentThreadId() @@@ if( ((oldhDC == NULL) && wsdo->window != NULL) || @@@ (info->wsdo != wsdo) || @@@ (info->wsdoTimeStamp != wsdo->timeStamp) ) @@@ ==> oldhDC = 0x2e010407, wsdo->window = 0x007b085c, info->wsdo = 0x53db6400, wsdo = 0x53db6400, info->wsdoTimeStamp = 26, wsdo->timeStamp = 26 @@@ 0 = SetDIBitsToDevice(hDC = 0x2e010407, XDest = 3, YDest = 25, dwWidth = 1594, dwHeight = 1142, XSrc = 0, YSrc = 0, uStartScan = 0, cScanLines = 1142, lpvBits = 0x1e2618a4, lpbmi = 0x541de810, fuColorUse = 0) @@@ GetLastError(): 87 @@@ GDIBlitLoops_nativeBlit end It uses its hDC = 0x2e010407 cached in thead local storage which was released at step 6. Obviously, painting to released hDC fails.
26-10-2015