EtheaDev / SVGIconImageList

Three engines to render SVG (Delphi Image32, Skia4Delphi, Direct2D wrapper) and four components to simplify use of SVG images (resize, fixedcolor, grayscale...)
Apache License 2.0
327 stars 96 forks source link

EMonitorLockException at FMX.SVGIconImageList unit's PaintToBitmap procedure #204

Closed birbilis closed 2 years ago

birbilis commented 3 years ago

image

The errors fires at CheckOwningThread after the following sequence (continuing from the place shown in the screenshot):

procedure TCanvas.EndScene;
begin
  try
    if FBeginSceneCount = 1 then
      DoEndScene;
    Dec(FBeginSceneCount);
  finally
    Unlock;
  end;
end;

class procedure TCanvas.Unlock;
begin
  TMonitor.Exit(FLock);
end;

class procedure TMonitor.Exit(const AObject: TObject);
begin
  CheckMonitorSupport;
  GetMonitor(AObject).Exit;
end;

procedure TMonitor.Exit;
var
  LockCount: Integer;
begin
  CheckOwningThread;
  Dec(FRecursionCount);
  if FRecursionCount = 0 then
  begin
    FOwningThread := 0;
    while True do
    begin
      LockCount := FLockCount;
      if AtomicCmpExchange(FLockCount, LockCount - 1, LockCount) = LockCount then
      begin
        // if LockCount is <> 0 after we dropped our lock, there were waiters, so signal them
        if LockCount and not 1 <> 0 then
          MonitorSupport.WaitOrSignalObject(GetEvent, nil, 0);
        Break;
      end;
    end;
  end;
end;

function TMonitor.CheckOwningThread: TThreadID;
begin
  Result := FOwningThread;
  if Result <> GetCurrentThreadId then
    Error(reMonitorNotLocked)
end;
birbilis commented 3 years ago

the whole callstack is here:

image

birbilis commented 3 years ago

There is a TSelection holding in it a TSVGIconImage (which has Align:=Contents) and the TSelection has Align:=Scale and is inside a TFrame (descendent) which is inside another such TSelection which is in turn inside a TFrame which is inside a TScrollBox which is inside a TForm (the idea is you have items that allow to manipulate [via control points of tselection] their contents and can nest infinitely).

Probably just placing the TSVGIconImage inside a TSelection on an FMX TForm and dragging arround the selection corners will cause that (think what I did was make one dimension of the selection too small, not sure if I hit zero there when it failed.

carloBarazzetta commented 3 years ago

I'm sorry but I have little experience with FMX, what I tried to do with these components was to try to provide an easy way to manage scalable icons, keeping source and destination "in sync", but I don't know if this is the cause of your problem... You would need some help from some more experienced FMX developer than me ..

carloBarazzetta commented 2 years ago

Did you find any solution or the cause of this problem?

birbilis commented 2 years ago

didn't happen again, but didn't try that case I mention above extensively (placing the TSVGIconImage inside a TSelection on an FMX TForm and dragging arround the selection corners), if I see it occuring again I will note it here (and for what version)

carloBarazzetta commented 2 years ago

Ok, thanks.