PictureBox Refresh Method Lag
PictureBox Refresh Method Lag
PictureBox Refresh Method Lag
PictureBox Refresh Method Lag
PictureBox Refresh Method Lag
PictureBox Refresh Method Lag PictureBox Refresh Method Lag PictureBox Refresh Method Lag PictureBox Refresh Method Lag PictureBox Refresh Method Lag PictureBox Refresh Method Lag PictureBox Refresh Method Lag PictureBox Refresh Method Lag
PictureBox Refresh Method Lag PictureBox Refresh Method Lag
PictureBox Refresh Method Lag
Go Back  Xtreme Visual Basic Talk > > > PictureBox Refresh Method Lag


Reply
 
Thread Tools Display Modes
  #1  
Old 07-11-2016, 02:51 PM
Cerian Knight's Avatar
Cerian KnightPictureBox Refresh Method Lag Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,193
Default PictureBox Refresh Method Lag


On Windows 7 with a PictureBox .Refresh (or .PaintPicture) method and no other controls visible on the form, the .Refresh drops frames when only writing to the picture DIB array.

Windows 'Desktop Composition' is enabled, AutoRedraw False, no Border, ClipControls false, no Caption.

To resolve this, I find I have to either show a control on the PictureBox or issue any draw method (e.g., PSet, Print, etc.) once to a visible part of the PictureBox.

This only happens on one of two PCs I've tested, and when the set FPS is around 20, this can easily be noticed (at about an actual 10 FPS).

Perhaps the draw call on that PC provides some priority to the 'Desktop Composition's virtual display buffer to render on time. Any other ideas what might be going on?
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #2  
Old 07-12-2016, 07:51 AM
dilettante's Avatar
dilettantePictureBox Refresh Method Lag dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

I wonder if something like a call to the DwmFlush function also applies to queued GDI operations? Win32 controls might have this included in their rendering logic, and perhaps some explicit GDI operations do while others do not? Or maybe some things get redirected to DirectX so those need flushing?

I'm clueless really. Just fishing for ideas.
Reply With Quote
  #3  
Old 07-14-2016, 11:19 AM
Cerian Knight's Avatar
Cerian KnightPictureBox Refresh Method Lag Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,193
Default

Since I'm not using GDI, that might be part of the issue. I might go that route for comparison.

When I explicitly call a DwmFlush, it caps the FPS to the refresh rate (or a factor of it) as expected, and fixes the issue on that monitor.

However, in doing so, my other test system (that was working fine) develops a sort-of stutter issue on just one of the two monitors attached to it where it periodically seems to skip frames. Perhaps the second monitor is also doing so, but I don't notice because of differences in LCD gate-to-gate response (as the monitors are different models, but same resolution).

Thanks for the response, its nudged me into a better direction. I'll end up porting this to .Net eventually anyway and end up with new variations on these sets of issues.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #4  
Old 07-18-2016, 12:48 PM
Cerian Knight's Avatar
Cerian KnightPictureBox Refresh Method Lag Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,193
Default

I got it sorted for all cases I've tested. The issue with DwmFlush on the system that was working without it has to do with the render pipeline within the AMD HD 7570 graphics card stalling under stress during very complex scenes at 75 Hz (even on the other monitor, but harder to notice). I backed both monitors down to 60Hz (since I understand Desktop Composition may be flaky if the monitors have mismatched refresh rates) and all is well. At home, on a single monitor, I have it working flawlessly at 1080p@120 Hz on an AMD Radeon R9 270.

Here is the code I used (to eliminate any occasional artifacts from other more common methods):
Code:
InvalidateRect picBMP.hwnd, ByVal 0&, False
UpdateWindow picBMP.hwnd
DwmFlush
Unfortunately the DwmFlush is C_Decl, so errors in the IDE (but not compiled) because of the return value. So, I cheated and changed the declaration from 'Function' to 'Sub'. If someone tells me that they are absolutely sure that actual stack corruption will occur, I'll switch it back and wrap it.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #5  
Old 07-19-2016, 07:45 AM
OnErr0r's Avatar
OnErr0rPictureBox Refresh Method Lag OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,774
Default

To prevent stack problems you can create a TLB using the Cdecl calling convention. Unfortunately, this still only works correctly compiled.
__________________
Quis custodiet ipsos custodues.
Reply With Quote
  #6  
Old 07-19-2016, 12:49 PM
dilettante's Avatar
dilettantePictureBox Refresh Method Lag dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

I'm getting pretty sick of Microsoft turning its nose up at us like this.

Using cdecl in a Win32 DLL is inexcusable.

They also created a number of new ActiveX libraries that would be fully VB6-usable except for tons of gratuitous unsupported data types in arguments to method calls, property get/setters, etc. Sure, we can hack together alternative interface typelibs but there is no reason for it.

I doubt most of it is even by accident or omission. I smell the fishy hand of Anders and his band of VB Killers who work at Microsoft these days.
Reply With Quote
Reply

Tags
picturebox, method, fps, false, draw, desktop, windows, .refresh, visible, ideas, easily, noticed, pcs, tested, set, priority, render, compositions, virtual, buffer, actual, display, call, time, issue


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
PictureBox Refresh Method Lag
PictureBox Refresh Method Lag
PictureBox Refresh Method Lag PictureBox Refresh Method Lag
PictureBox Refresh Method Lag
PictureBox Refresh Method Lag
PictureBox Refresh Method Lag PictureBox Refresh Method Lag PictureBox Refresh Method Lag PictureBox Refresh Method Lag PictureBox Refresh Method Lag PictureBox Refresh Method Lag PictureBox Refresh Method Lag
PictureBox Refresh Method Lag
PictureBox Refresh Method Lag
 
PictureBox Refresh Method Lag
PictureBox Refresh Method Lag
 
-->