Wesley Bobato 0 Posted July 28, 2019 Hello everyone, I created a simple project that uses Camera and Effects with FMX unfortunately this project is generating some unknown runtime errors I can't find the root of the problem I added in the DPR file all FMX options 1. Slow processing when GlobalUseGPUCanvas = false2. When I use the effects after a while it crashes, it does not allow to stop the camera and etc. To generate the different errors you can uncomment the lines of the DPR file.1. Activate the camera.2. Click on effects.3. Use the effects options.4. Disable the camera.5. Repeat steps 1 through 4. DPR file lines to uncomment. // GlobalUseHWEffects := False; // GlobalDisableFocusEffect := True; // GlobalUseDX := False; // GlobalUseDXInDX9Mode := True; // GlobalUseDXSoftware := True; // GlobalUseDirect2D := False; // GlobalUseGDIPlusClearType := False; // GlobalUseGPUCanvas := True; // GlobalUseDX10 := False; // GlobalUseDX10Software := False; I added FastMM4 is commented in the DPR file // FastMM4, As you use the effects combining with DPR file options uncomment the different lines kinds of problems appear. I noticed that the amount of camera FPS gets smaller at times as well. I am using Windows 7 SP1 and Delphi 10.3.2, errors appear in Win 32/64 Debug and Release environment. Could someone help me locate these errors for me to create a ticket in the quality portal of embarcadero? Thank you all. [Download] Camera.zip Share this post Link to post
f.m 8 Posted July 30, 2019 (edited) procedure TForm1.SampleBufferReady(Sender: TObject; const ATime: TMediaTime); begin if FUpdatePreviewExecuting then Exit; .. end; procedure TForm1.SetEffect(const AFilterName: string); begin if FUpdatePreviewExecuting then Exit; ... end; procedure TForm1.UpdatePreview; begin FUpdatePreviewExecuting := True; try FFilter.ValuesAsBitmap[ 'Input' ] := FRawBitmap; if not FTargetBitmap.IsEmpty then FFilter.ValuesAsBitmap[ 'Target' ] := FTargetBitmap; imgCam.Bitmap := FFilter.ValuesAsBitmap[ 'Output' ]; finally FUpdatePreviewExecuting := False; end; end; SampleBufferReady() is probably synchronized via TThread.Synchronize(). Try to protect UpdatePreview() with a flag. Edited July 30, 2019 by f.m Share this post Link to post
f.m 8 Posted July 31, 2019 Hi, I add some information. I tested your project in the following configuration: - 10.3.2, Windows 10; - I have not removed the comment to any of the Global.. flags in DPR file; - I didn't use FastMM4. I performed two tests: A) Without using TVideoCaptureDevice. I used a timer and some images: The program works. It is possible to change effects, and use effects options without errors. This leads me to believe that the problem is TVideoCaptureDevice: B) Using TVideoCaptureDevice. Generates exception, which is removed if I use the flag ("if FUpdatePreviewExecuting..") in the SampleBufferReady () method. Test procedure: 1) [Play] 2) [Effect] 3) Click on effect 4) Changing effect parameters 5) Repeat from step 3. Share this post Link to post
Wesley Bobato 0 Posted August 1, 2019 @f.m thank you very much for your generous attention again :) I tested your suggestion but unfortunately generated a very long delay was crashing a lot. Based on your suggestion I changed a few lines. Quote procedure TForm1.UpdatePreview; begin TThread.CreateAnonymousThread( procedure() begin FFilter.ValuesAsBitmap[ 'Input' ] := FRawBitmap; if not FTargetBitmap.IsEmpty then FFilter.ValuesAsBitmap[ 'Target' ] := FTargetBitmap; TThread.Synchronize( TThread.Current, procedure() begin imgCam.Bitmap := FFilter.ValuesAsBitmap[ 'Output' ]; end ); end ).Start; end; This didn't work correctly either, but it is having a shorter delay. When you have thrown exceptions on your computer you can capture which unit or line of code it is in. is this occurring? Here on my computer I can't capture the location of the problem even with Debug and FastMM4. I believe there is a problem with TVideoCaptureDevice but it is very difficult to capture the location Do you know any way to track where these exceptions occur in Delphi? Kind regards. Share this post Link to post
f.m 8 Posted August 2, 2019 Hi, This exception occurs in the FMX.Canvas.D2D file on the line 1996 . Share this post Link to post
Dave Nottage 557 Posted August 2, 2019 A stack trace would be more helpful. It should appear after you click "Break". If not, click View > Debug Windows > Call Stack or just use Ctrl-Alt-S Share this post Link to post
f.m 8 Posted August 2, 2019 Thank you. Here is the stack trace: The exception occurs in the original version of the code. By protecting the UpdatePreview () method with a flag, this exception does not occur. Share this post Link to post
Wesley Bobato 0 Posted August 3, 2019 Thanks a lot @Dave and @fm I will try to track these errors in the coming days I will post here soon. Share this post Link to post
Wesley Bobato 0 Posted August 4, 2019 Hello it is very difficult to find the possible locations where the problem occurs, my intuition after examining all the points of the stack, is that the problem is related to "FMX.Media" some synchronization not working properly, I get several errors after a few minutes of testing. Particularly the line reported by @fm did not occur here in my tests, I tested this project's compile on another computer and got different errors on Win10. Any suggestions how I can report this to embarcadero? Thank you all. Share this post Link to post