Skip to content
View in the app

A better way to browse. Learn more.

FGX Native

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[TfgCameraPreview] Preview stays black when its form is created before it is shown (iOS)

  • 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:

  • IsBufferAvailable returns True, so the surface exists and the preview is attached
    to the camera

  • CalculatedFrameRect is correct (e.g. 537.75 x 956 for a 440 pt wide control, the
    usual AspectFill overhang)

  • size 440 x 956, Visible = True, form visible, no error overlay

  • all 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 but
TfgCamera + 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 a
TfgLayout with a background, an infinitely repeating scale animation, Enabled = False
on the preview, calling RequestPermission in the constructor, registering a
TfgNavigationBar 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.

User Feedback

Recommended Comments

There are no comments to display.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.