Updating Progress Label During Long Calculation in Start

Thank you – we had a bug in the engine that made TThread.Synchronize do nothing when used with CastleWindow (not LCL) with FPC.

Fixed now :slight_smile: in this commit. As usual, the engine download will soon contain the fixed version, once the new engine passes a few automated tests. You can observe this page, when it will no longer contain a commit titled “Make TThread.Synchronize work in FPC applications using CastleWindow…” then the fix is part of download.

So this makes your example work the same with FPC and Delphi.

Update: A subsequent commit fixes FPC+Android which required one thing to be correct. So please wait until also the commit titled “Set MainThreadID on Android…” is part of the downloads, to have it working flawlessly on FPC+Android too.

That said:

Your application calls CGE API from non-main thread. The application you send is already not guaranteed to work.

Please heed the warning I mentioned a few posts above and emphasized on threads manual page:

The application you submitted does use CGE API from non-main thread:

  • you iterate over X3D graph,
  • you do Target.RootNode.AddRoute,
  • you setup TCastleCapsuleCollider

← you do these things in TViewMain.DoLoad and CopyAnimationOnly which are not in the main thread.

I understand what you’re trying to solve (speedup animation copying by threads) but this way is really not reliable. It may work by accident (it seems it does now, at least in the simple application you submitted, but evidently your larger application has random errors). Our API is not thread-safe (and it’s the same as LCL, VCL, or other game engines).

If you want to speedup animation → this can likely be done by just making that code faster, even in single thread. I see your testcase in Sharing Animations Between Multiple Characters With the Same Skeleton - #19 by michalis – thank you, I have it on TODO to investigate and propose a speedup.

1 Like