Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TCameraComponent problems?


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 13 - Last Post: Feb 9, 2017 10:54 AM Last Post By: Markus Humm
Michael Gonyea

Posts: 10
Registered: 4/6/12
TCameraComponent problems?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 25, 2017 2:19 PM
Hey folks,

We've developed a cross-platform application in Delphi that's using the TCameraComponent; however, the application has been having problems when utilizing the camera component on an iOS device. The symptoms are:

1) We start the camera (via CameraComponent.Active := True)
2) We capture the picture (via SampleBufferToBitmap(...))
3) We stop the camera (via CameraComponent.Active := False)
4) etc..
5) App gets sent to background when accessing camera after <n> attempts

Now, after several Start/Stop camera sequences, the application gets pushed into the background automatically (almost like hitting the home button to suspend an app on iOS). Occasionally (but not always), we'll receive an error in the Console stating "Received Memory Warning" which I had originally attributed to our app not clearing out Bitmap memory from a preview control, memory stream, etc. After many unsuccessful runs and debugging, I decided to build and install the CameraComponent sample provided onto my iOS device. It turns out the sample app has the exact same problem. I'll describe my environment below and hopefully someone can help:

OS: Window 7 (fully updated via Windows Update)
IDE: Delphi 10.2 Berlin
Sample App: CameraComponent (obtained from https://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RADStudio_Berlin/Object%20Pascal/Mobile%20Snippets/CameraComponent/)
Target Device: iPad Air; iOS 10.2.1; 32GB
Additional Target Device: iPhone 6s; iOS 10.2.0
PAServer: 18.0 (running on Mac OSX)

Steps to reproduce:

1) Start the sample application on an iOS Device (64-bit)
2) Tap "Start Camera", wait for preview window, then tap "Stop Camera"
3) Repeat step #2 over and over again and eventually the app will suspend into the background; you may/may not get to see the "Received memory warning" issue in the device logs (if you're viewing logs via XCode/Console)

Is there something wrong with the TCameraComponent (or the demo code) that's "crashing/suspending" the application somehow? Our implementation follows the demo accurately and we're unable to determine what the cause is.

Thanks in advance!
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: TCameraComponent problems? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 25, 2017 2:42 PM   in response to: Michael Gonyea in response to: Michael Gonyea
Michael Gonyea wrote:

Is there something wrong with the TCameraComponent (or the demo code) that's "crashing/suspending" the application
somehow?

More than likely. Check the crash logs:

https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/AnalyzingCrashReports/AnalyzingCrashReports.html

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Michael Gonyea

Posts: 10
Registered: 4/6/12
Re: TCameraComponent problems? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 25, 2017 2:46 PM   in response to: Dave Nottage in response to: Dave Nottage
No crash report is generated when this problem occurs (the app doesn't appear to die off completely, only gets sent to the background.)
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: TCameraComponent problems? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 25, 2017 2:50 PM   in response to: Michael Gonyea in response to: Michael Gonyea
Michael Gonyea wrote:

No crash report is generated when this problem occurs (the app doesn't appear to die off completely, only gets sent
to the background.)

There should at least be some clue in the device logs, then.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Michael Gonyea

Posts: 10
Registered: 4/6/12
Re: TCameraComponent problems? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 25, 2017 3:31 PM   in response to: Dave Nottage in response to: Dave Nottage
Nothing remotely useful:

{
  "crashReporterKey" : "9250564f4006d2fd1728b52ff9043dcd7b562eaf",
  "kernel" : "Darwin Kernel Version 16.3.0: Thu Dec 15 22:41:46 PST 2016; root:xnu-3789.42.2~1\/RELEASE_ARM64_S5L8960X",
  "product" : "iPad4,1",
  "incident" : "A99C1145-9FE5-4416-814D-61A9CF33D6E5",
  "date" : "2017-01-25 15:27:20.64 -0800",
  "build" : "iPhone OS 10.2.1 (14D27)",
  "timeDelta" : 147,
  "memoryStatus" : {
  "compressorSize" : 12850,
  "pageSize" : 4096,
  "compressions" : 3917484,
  "memoryPages" : {
    "active" : 6894,
    "throttled" : 0,
    "fileBacked" : 12365,
    "wired" : 216628,
    "anonymous" : 5868,
    "purgeable" : 0,
    "inactive" : 10617,
    "free" : 821,


I even boiled it down to something much simpler. I create a multi-device app with only two buttons: one to set the camera active = True, and another to set the camera active = False. No preview image, SampleBufferToBitmap, etc.. - just turn on, turn off and it still suspends to the background. This seems very likely that it is an internal issue with TCameraComponent.

We are very familiar with the logging tools and Instruments in XCode, etc. but there is no additional information in device logs, console logs, IDE messages, etc. to add to this post. I'm hoping someone will come along to discover/provide a solution to this.
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: TCameraComponent problems? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 26, 2017 9:00 AM   in response to: Michael Gonyea in response to: Michael Gonyea
Am 26.01.2017 um 00:31 schrieb Michael Gonyea:
Nothing remotely useful:

{
  "crashReporterKey" : "9250564f4006d2fd1728b52ff9043dcd7b562eaf",
  "kernel" : "Darwin Kernel Version 16.3.0: Thu Dec 15 22:41:46 PST 2016; root:xnu-3789.42.2~1\/RELEASE_ARM64_S5L8960X",
  "product" : "iPad4,1",
  "incident" : "A99C1145-9FE5-4416-814D-61A9CF33D6E5",
  "date" : "2017-01-25 15:27:20.64 -0800",
  "build" : "iPhone OS 10.2.1 (14D27)",
  "timeDelta" : 147,
  "memoryStatus" : {
  "compressorSize" : 12850,
  "pageSize" : 4096,
  "compressions" : 3917484,
  "memoryPages" : {
    "active" : 6894,
    "throttled" : 0,
    "fileBacked" : 12365,
    "wired" : 216628,
    "anonymous" : 5868,
    "purgeable" : 0,
    "inactive" : 10617,
    "free" : 821,


I even boiled it down to something much simpler. I create a multi-device app with only two buttons: one to set the camera active = True, and another to set the camera active = False. No preview image, SampleBufferToBitmap, etc.. - just turn on, turn off and it still suspends to the background. This seems very likely that it is an internal issue with TCameraComponent.

We are very familiar with the logging tools and Instruments in XCode, etc. but there is no additional information in device logs, console logs, IDE messages, etc. to add to this post. I'm hoping someone will come along to discover/provide a solution to this.

Hello,

as you have a simplified test program and can reproduce the case (is the
number of on/off cycles always the same when it happens?)
I'd like you to file a QP report over at quality.embarcadero.com
and add your sample app in source code.

Then come back and post the report number so we may look at it, vote for
it, track it, help when the description shouldn't yet be 100% clear
enough whatever...
...add our experience as comment.

Greetings

Markus
Michael Gonyea

Posts: 10
Registered: 4/6/12
Re: TCameraComponent problems? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 26, 2017 10:54 AM   in response to: Markus Humm in response to: Markus Humm
Hey Markus,

I can definitely do that - I was having troubles logging into the QC site yesterday but will try again today. I'm not sure if it's the exact same # of On/Off sequences that triggers it, but it doesn't take long before the app suspends to the background (between 5-10 cycles in recent tests).

I will update this task with the QC issue # as requested.

Edited by: Michael Gonyea on Jan 26, 2017 10:54 AM
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: TCameraComponent problems? [Edit] [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 27, 2017 5:31 AM   in response to: Michael Gonyea in response to: Michael Gonyea
Am 26.01.2017 um 19:54 schrieb Michael Gonyea:
Hey Markus,

I can definitely do that - I was having troubles logging into the QC site yesterday but will try again today. I'm not sure if it's the exact same # of On/Off sequences that triggers it, but it doesn't take long before the app suspends to the background (between 5-10 cycles in recent tests).

I will update this task with the QC issue # as requested.

Edited by: Michael Gonyea on Jan 26, 2017 10:54 AM

HGello,

you shall use QP, not QC. QP is quality.embarcadero.com and uses the
same login as the forum website and EDN. QC is the old system.

Greetings

Markus
Michael Gonyea

Posts: 10
Registered: 4/6/12
Re: TCameraComponent problems?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 2, 2017 1:20 PM   in response to: Michael Gonyea in response to: Michael Gonyea
My apologies for this delayed response - had to focus on another project this past week.

As requested, here is the Issue reported to Embarcadero QP: https://quality.embarcadero.com/browse/RSP-16812
Michael Gonyea

Posts: 10
Registered: 4/6/12
Re: TCameraComponent problems?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 7, 2017 4:25 PM   in response to: Michael Gonyea in response to: Michael Gonyea
Hey folks,

For those not involved in the Embarcadero QR investigation into this issue, here's some additional info:

The device records a Jetsam.ips crash report containing the following:

{ "uuid" : "ca7d4fd9-fa88-3ba0-b75d-3ac910ff70f2", "states" : [ "frontmost", "resume" ], "killDelta" : 2107, "genCount" : 0, "age" : 874312286, "purgeable" : 0, "fds" : 50, "coalition" : 533, "rpages" : 181192, "reason" : "per-process-limit", "pid" : 564, "cpuTime" : 2.622752, "name" : "CameraIssue", "lifetimeMax" : 9309 }

More specifically, take a look at the "Reason:" above - per-process-limit (indicates memory consumption issues)

All the test app does is toggle between TCameraComponent.Active=True and TCameraComponent.Active=False over a period of time (5-10 on/off cycles when testing on iPad Air 32GB, 20-30 on/off cycles when testing on iPad Pro 64GB)

Looks very much like memory leak when using the component in a very basic manner.
Jeremy North

Posts: 402
Registered: 9/20/99
Re: TCameraComponent problems?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 7, 2017 6:19 PM   in response to: Michael Gonyea in response to: Michael Gonyea
Michael Gonyea wrote:
Hey folks,

For those not involved in the Embarcadero QR investigation into this issue, here's some additional info:

The device records a Jetsam.ips crash report containing the following:

{ "uuid" : "ca7d4fd9-fa88-3ba0-b75d-3ac910ff70f2", "states" : [ "frontmost", "resume" ], "killDelta" : 2107, "genCount" : 0, "age" : 874312286, "purgeable" : 0, "fds" : 50, "coalition" : 533, "rpages" : 181192, "reason" : "per-process-limit", "pid" : 564, "cpuTime" : 2.622752, "name" : "CameraIssue", "lifetimeMax" : 9309 }

More specifically, take a look at the "Reason:" above - per-process-limit (indicates memory consumption issues)

All the test app does is toggle between TCameraComponent.Active=True and TCameraComponent.Active=False over a period of time (5-10 on/off cycles when testing on iPad Air 32GB, 20-30 on/off cycles when testing on iPad Pro 64GB)

Looks very much like memory leak when using the component in a very basic manner.

I agree. I've been prototyping something using this component and just toggling between Front and Back cameras a few times is causing the app to crash.
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: TCameraComponent problems?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 7, 2017 8:59 PM   in response to: Michael Gonyea in response to: Michael Gonyea
For those not involved in the Embarcadero QR investigation into this issue, here's some additional info:

The device records a Jetsam.ips crash report containing the following:

{ "uuid" : "ca7d4fd9-fa88-3ba0-b75d-3ac910ff70f2", "states" : [ "frontmost", "resume" ], "killDelta" : 2107, "genCount" : 0, "age" : 874312286, "purgeable" : 0, "fds" : 50, "coalition" : 533, "rpages" : 181192, "reason" : "per-process-limit", "pid" : 564, "cpuTime" : 2.622752, "name" : "CameraIssue", "lifetimeMax" : 9309 }

More specifically, take a look at the "Reason:" above - per-process-limit (indicates memory consumption issues)

All the test app does is toggle between TCameraComponent.Active=True and TCameraComponent.Active=False over a period of time (5-10 on/off cycles when testing on iPad Air 32GB, 20-30 on/off cycles when testing on iPad Pro 64GB)

Looks very much like memory leak when using the component in a very basic manner.

Thanks; I'll be looking into it tomorrow.

--
Dave Nottage [TeamB]
Delphi Worlds blog: http://www.delphiworlds.com/blog
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: TCameraComponent problems?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 8, 2017 4:20 PM   in response to: Dave Nottage in response to: Dave Nottage
I wrote:

Looks very much like memory leak when using the component in a very basic manner.

Thanks; I'll be looking into it tomorrow.

I've spent some time looking mostly at the code to determine where the leak might be happening. Having followed the
execution paths, I expect it is somewhere in TAVVideoCaptureDevice.DoStartCapture in FMX.Media.AVFoundation, however I
am yet to determine where exactly. I've run out of time for this one at the moment.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: TCameraComponent problems?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 9, 2017 10:54 AM   in response to: Dave Nottage in response to: Dave Nottage
Am 09.02.2017 um 01:20 schrieb Dave Nottage (TeamB):
I wrote:

Looks very much like memory leak when using the component in a very basic manner.

Thanks; I'll be looking into it tomorrow.

I've spent some time looking mostly at the code to determine where the leak might be happening. Having followed the
execution paths, I expect it is somewhere in TAVVideoCaptureDevice.DoStartCapture in FMX.Media.AVFoundation, however I
am yet to determine where exactly. I've run out of time for this one at the moment.

Great that you investigated so far already!
Keep up that work when time permits!

Greetings

Markus
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02