vcl/skia/gdiimpl.cxx |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit aff4c1055e95f04d794ef83105f4a20ac16159db
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Dec 31 17:04:36 2023 +0600
Commit:     Patrick Luby <plub...@libreoffice.org>
CommitDate: Mon Jan 1 15:24:23 2024 +0100

    Avoid unwanted creation of mSurface
    
    Commit 2d1a0d86d2d0c00fcfee61c39f2221e786e4245b (Related: tdf#152703
    Prevent possible hang when live resizing a window, 2023-01-06) had
    added a call to checkSurface in SkiaSalGraphicsImpl::performFlush,
    to detect resize.
    
    This created a regression, seen e.g. in JunitTest_framework_complex,
    where 'assert(!mSurface)' in SkiaSalGraphicsImpl dtor fails now on
    Windows with Skia/Vulkan:
    
     vcllo.dll!SkiaSalGraphicsImpl::~SkiaSalGraphicsImpl() Line 296 C++
     vclplug_winlo.dll!WinSkiaSalGraphicsImpl::~WinSkiaSalGraphicsImpl()    C++
     vclplug_winlo.dll!WinSkiaSalGraphicsImpl::`scalar deleting 
destructor'(unsigned int)   C++
     
vclplug_winlo.dll!std::default_delete<SalGraphicsImpl>::operator()(SalGraphicsImpl
 * _Ptr) Line 3170   C++
     
vclplug_winlo.dll!std::unique_ptr<SalGraphicsImpl,std::default_delete<SalGraphicsImpl>>::~unique_ptr<SalGraphicsImpl,std::default_delete<SalGraphicsImpl>>()
 Line 3282 C++
     vclplug_winlo.dll!WinSalGraphics::~WinSalGraphics() Line 668   C++
     vclplug_winlo.dll!WinSalGraphics::`scalar deleting destructor'(unsigned 
int)   C++
     vclplug_winlo.dll!WinSalFrame::~WinSalFrame() Line 977 C++
     vclplug_winlo.dll!WinSalFrame::`scalar deleting destructor'(unsigned int)  
    C++
     vclplug_winlo.dll!SalComWndProc(HWND__ * __formal, unsigned int nMsg, 
unsigned __int64 wParam, __int64 lParam, bool & rDef) Line 667   C++
     vclplug_winlo.dll!SalComWndProcW(HWND__ * hWnd, unsigned int nMsg, 
unsigned __int64 wParam, __int64 lParam) Line 724   C++
     user32.dll!00007ffaab908241()  Unknown
     user32.dll!00007ffaab907efc()  Unknown
     user32.dll!00007ffaab91302d()  Unknown
     ntdll.dll!00007ffaac2d33b4()   Unknown
     win32u.dll!00007ffaa97814d4()  Unknown
     user32.dll!00007ffaab911b4f()  Unknown
     user32.dll!00007ffaab911a1c()  Unknown
     sal3.dll!osl_waitCondition(void * Condition, const TimeValue * pTimeout) 
Line 93       C++
     vclplug_winlo.dll!osl::Condition::wait(const TimeValue * pTimeout) Line 
124    C++
     vclplug_winlo.dll!SalYieldMutex::doAcquire(unsigned long nLockCount) Line 
140  C++
     comphelper.dll!comphelper::SolarMutex::acquire(unsigned long nLockCount) 
Line 87       C++
     vcllo.dll!SalInstance::AcquireYieldMutex(unsigned long nCount) Line 147    
    C++
     vcllo.dll!Application::AcquireSolarMutex(unsigned long nCount) Line 510    
    C++
     vclplug_winlo.dll!SolarMutexReleaser::~SolarMutexReleaser() Line 1420  C++
     vclplug_winlo.dll!WinSalInstance::DoYield(bool bWait, bool 
bHandleAllCurrentEvents) Line 586   C++
     vcllo.dll!ImplYield(bool i_bWait, bool i_bAllEvents) Line 390  C++
     vcllo.dll!Application::Yield() Line 475        C++
     vcllo.dll!Application::Execute() Line 368      C++
     sofficeapp.dll!desktop::Desktop::Main() Line 1605      C++
     vcllo.dll!ImplSVMain() Line 229        C++
     vcllo.dll!SVMain() Line 262    C++
     sofficeapp.dll!soffice_main() Line 94  C++
     soffice.bin!sal_main() Line 51 C
     soffice.bin!main(int argc, char * * argv) Line 49      C
     soffice.bin!invoke_main() Line 79      C++
     soffice.bin!__scrt_common_main_seh() Line 288  C++
     soffice.bin!__scrt_common_main() Line 331      C++
     soffice.bin!mainCRTStartup(void * __formal) Line 17    C++
     kernel32.dll!00007ffaab01257d()        Unknown
     ntdll.dll!00007ffaac28aa58()   Unknown
    
    This is caused by unwanted creation of mSurface in checkSurface,
    outside of the Init/DeInit pair, called from WinSalGraphics'
    InitGraphics/DeInitGraphics. Thus an invariant is broken, that
    only when WinSalFrame initializes its mhLocalDC, its mpImpl is
    initialized. Deinitialization of mpImpl is thus only called if
    mhLocalDC is not null.
    
    Since flush makes no sense without mSurface, just move the call
    to checkSurface inside the mSurface check. Hope it doesn't break
    the fix made in commit 2d1a0d86d2d0c00fcfee61c39f2221e786e4245b.
    
    Change-Id: I54442e604ef7c28659b908a7fb1404c9da41b006
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161484
    Reviewed-by: Patrick Luby <plub...@libreoffice.org>
    Tested-by: Jenkins
    (cherry picked from commit 78ff693225e015e9f3153e26fbd4dca5fa1f0095)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161413
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index e4e71798da48..485eaf24618d 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -393,13 +393,13 @@ void SkiaSalGraphicsImpl::performFlush()
 {
     SkiaZone zone;
     flushDrawing();
-    // Related: tdf#152703 Eliminate flickering during live resizing of a 
window
-    // When in live resize, the SkiaSalGraphicsImpl class does not detect that
-    // the window size has changed until after the flush has been called so
-    // call checkSurface() to recreate the SkSurface if needed before flushing.
-    checkSurface();
     if (mSurface)
     {
+        // Related: tdf#152703 Eliminate flickering during live resizing of a 
window
+        // When in live resize, the SkiaSalGraphicsImpl class does not detect 
that
+        // the window size has changed until after the flush has been called so
+        // call checkSurface() to recreate the SkSurface if needed before 
flushing.
+        checkSurface();
         if (mDirtyRect.intersect(SkIRect::MakeWH(GetWidth(), GetHeight())))
             flushSurfaceToWindowContext();
         mDirtyRect.setEmpty();

Reply via email to