- Status: Reported
- Priority: Normal
- Resolution: Unresolved
- Platform: iOS
- Affects version 1.20.1.0
Environment
FGX Native 1.20.1.0
RAD Studio 13 (BDS 37.0), iOSDevice64, Debug
iPhone 17 Pro Max, built against iPhoneOS27.0.sdk
Android: same code works fine
Problem
If a form containing a TfgCameraPreview is created but not shown right away, the
preview stays black forever on iOS — even after the form is shown later and the camera
has started.
The camera itself works perfectly in this state: the session starts, OnStateChanged
reports Started, and an attached TfgBarcodeScanner keeps detecting barcodes. Only the
preview shows nothing.
How to reproduce
// A: preview stays black
constructor TScannerHolder.Create;
begin
inherited;
FForm := TFormScanner.Create(nil); // created here, shown later
end;
procedure TScannerHolder.Scan;
begin
FForm.Show; // black preview, camera is running
end;
// B: works
procedure TScannerHolder.Scan;
begin
if FForm = nil then
FForm := TFormScanner.Create(nil); // created right before showing
FForm.Show;
end;
The form itself is unchanged between A and B — only the moment of creation differs.
What makes this hard to diagnose
Everything you would normally check looks correct while the preview is black:
IsBufferAvailablereturnsTrue, so the surface exists and the preview is attached
to the cameraCalculatedFrameRectis correct (e.g.537.75 x 956for a 440 pt wide control, the
usualAspectFilloverhang)size
440 x 956,Visible = True, form visible, no error overlayall events run on the main thread, only one form instance exists
no exception is raised anywhere
I verified it is none of the usual suspects by taking a bare TfgForm with nothing butTfgCamera + TfgCameraPreview (which works) and adding the properties of the failing
form one at a time. All of these kept the picture alive: a custom base form class,
a TfgBarcodeScanner attached to the same camera, nesting the preview inside aTfgLayout with a background, an infinitely repeating scale animation, Enabled = False
on the preview, calling RequestPermission in the constructor, registering aTfgNavigationBar as Toolbar plus SystemStatusBar.Visibility = Invisible, two
full-size overlay layouts, TfgArc / TfgActivityIndicator / TfgLabel / icon buttons,
and the exact same call path. The picture only disappeared when the form was created in
advance instead of immediately before Show.
What I noticed in the log: when the form is created in advance, OnResized of the
preview already fires at creation time — so the preview is laid out (and its surface
created) while the form has never been on screen. That surface seems to stay unusable.
Workaround
Create the form lazily, right before showing it.
Question
Is this expected? If a preview may not be laid out before its form is shown, it would
help a lot if FGX either re-created the surface on the first Show, or logged a warning —
right now nothing indicates that anything is wrong.
Recommended Comments
Create an account or sign in to comment