metal_capture_util 0.0.2 copy "metal_capture_util: ^0.0.2" to clipboard
metal_capture_util: ^0.0.2 copied to clipboard

PlatformiOSmacOS

A Metal Capture utility for Flutter applications on iOS/macOS.

metal_capture_util #

A utility package for Flutter to invoke MTLCaptureManager APIs on iOS and macOS to inspect Metal commands.

Usage #

First, make sure to set MetalCaptureEnabled to YES in your app's Info.plist file:

<key>MetalCaptureEnabled</key>
<true/>

After adding the metal_capture_util dependency, you can use it as follows:

import 'package:metal_capture_util/metal_capture_util.dart';

// Programmatic capture with custom start/stop points
// (macOS only) If openFile is set to `true`, the captured file will be opened in Xcode automatically.
// (iOS only) See below on how to pull the capture file from an external device.

MetalCapture.beginCapture();
// ... your Metal rendering code (e.g. with flutter_gpu) ...
MetalCapture.endCapture({openFile: true});

// Capture the next full frame from Flutter
// This will schedule a new forced frame and capture it.
await MetalCapture.captureNextFrame({openFile: true});

For iOS, you can register a service extension to pull the capture file from an external device:


void main() {
  WidgetsFlutterBinding.ensureInitialized();
  MetalCapture.registerServiceExtension();
  runApp(MyApp());
}

Then, you can use the provided CLI tool to pull the capture file:

# Replace the VM service URI with the one from your console
dart run metal_capture_util ws://127.0.0.1:59582/RJ2kNeCMQgU=/ws

Future plans #

  • Capturing the frame seems to be inconsistent sometimes.
  • Support for Android using renderdoc.
  • Expose this package as a vm service extension or a devtools plugin.

Contact me #

Feel free to contact me at:

E-mail: [email protected]

0
likes
140
points
3
downloads

Publisher

verified publisherkekland.com

Weekly Downloads

A Metal Capture utility for Flutter applications on iOS/macOS.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

ffi, flutter, objective_c, vm_service

More

Packages that depend on metal_capture_util

Packages that implement metal_capture_util