Recent

Author Topic: MPHexEditor, large files scrolling  (Read 1066 times)

DIMM_bl4

  • Newbie
  • Posts: 2
MPHexEditor, large files scrolling
« on: January 31, 2021, 09:27:53 pm »
Hello to all, my first message here.
Have a some trouble with MPHexEditor module, when open large files scrolling became very slow. This is slightly noticeable from 16-32MB size and go worst with increasing size.
First of all, I go to example project, and see exactly the same.
Lazarus is 2.0.10, FPC 3.2.0, MPHexEditor from here https://github.com/michalgw/mphexeditor

I tried to solve by myself, but looks like I'm not strong enough )
Found that things:
There are used two ways for scrolling
1. Scroll with keyboard/mousewheel do with changing of 'TopRow' property, and this way is slow.
2. Scroll with side scrollbar is totally differrent and uses 'WMHScroll(var message: TLMHScroll)' and then 'TrySmoothScrollBy(Col, Row)' from module Grids. This way work always fast, with any file size.

Would appreciate any help, or thoughts )

korba812

  • Full Member
  • ***
  • Posts: 179
Re: MPHexEditor, large files scrolling
« Reply #1 on: February 02, 2021, 06:35:19 pm »
This is a known issue. The problem is with TCustomGrid, from which TMPHexEdit inherits. I have attached a sample project to illustrate the problem. Other problems with using TCustomGrid are excessive memory consumption and row limit.
This is the main reason why I stopped further development of TMPHexEdit. It should probably be redesigned from scratch.

DIMM_bl4

  • Newbie
  • Posts: 2
Re: MPHexEditor, large files scrolling
« Reply #2 on: February 02, 2021, 07:28:51 pm »
Thanks for reply.
I made a 'temporary' solution - modified procedures KeyDown, DoMouseWheelDown, DoMouseWheelUp from MPHexEditor.pas to also use TrySmoothScrollBy(aCol, aRow) from module Grids (as a scrollbar scrolling).
But for this I had to also modify module Grids.pas, for possibility to call TrySmoothScrollBy from outside. I moved it from 'private' declaration to 'protected', same as for some procedures, called from outside.
I'm not 100% sure about any side effects, but looks like working good.
I attach modified example .exe from MPHexEditor, now it can scrolls up to ~512MBytes files, original example freezed to death (with 100% load to one thread) with constant scrolling at about 32Mbytes files.
https://yadi.sk/d/7LU_sUxo1Zvk2Q

The problem is with TCustomGrid, from which TMPHexEdit inherits ...
I can not totally agree, because I also tryed to use 'parent' versions of procedures DoMouseWheelDown, DoMouseWheelUp, and scrolling became fast (no freeze)...but at one line per wheel's 'tick'.

korba812

  • Full Member
  • ***
  • Posts: 179
Re: MPHexEditor, large files scrolling
« Reply #3 on: February 02, 2021, 09:12:48 pm »
IMHO, a better solution will be to expand functionality of TCustomGrid component. The TCustomGrid.UpdateCachedSizes method is called quite often. This function sums height of all rows, so it takes a while for a large number of rows. In many cases, all rows have the same height and there is no point in storing it. I would suggest adding a mode where all rows (or at least non-fixed) have the same height and not store their height values. This will eliminate the problem with slowdown and high memory consumption.

 

TinyPortal © 2005-2018