Skip to content

nativeTexture FFI lookup targets wrong DLL and renderTextureObjPtr getter missing in lib/src/rive_native_ffi.dart #612

@unspokenlanguage

Description

@unspokenlanguage

Description
Two issues in rive_native_ffi.dart on Windows:

A) Wrong DLL for nativeTexture lookup.

_nativeTexture is looked up from DynamicLibraryHelper.nativeLib, which resolves to rive_native.dll (the prebuilt library). On Windows, nativeTexture is not exported from rive_native.dll, causing a runtime crash:

Invalid argument(s): Failed to lookup symbol 'nativeTexture': 
error code 127 (The specified procedure could not be found.)

B) Missing renderTextureObjPtr getter.

_NativeRenderTexture exposes nativeRendererPointer (a Pointer), but not its integer address. Method channels cannot transport Pointer, so external bridges need the raw int address.

Changes We Made
A) Platform-conditional DLL resolution:

import 'dart:io' as io;

final DynamicLibrary nativeLib = DynamicLibraryHelper.nativeLib;

// On Windows, nativeTexture is exported from rive_native_plugin.dll (the
// Flutter plugin wrapper), not from rive_native.dll (the prebuilt Rive lib).
final DynamicLibrary _pluginLib = io.Platform.isWindows
    ? DynamicLibrary.open('rive_native_plugin.dll')
    : nativeLib;

// Changed from: nativeLib.lookup(...)
final Pointer<Void> Function(Pointer<Void>) _nativeTexture = _pluginLib
    .lookup<NativeFunction<Pointer<Void> Function(Pointer<Void>)>>(
      'nativeTexture',
    )
    .asFunction();

B) Added getter to
_NativeRenderTexture
:

dart

@override
  Pointer<Void> get nativeRendererPointer => _rendererPtr;
  /// The raw address of the native renderer object, suitable for passing
  /// through method channels to native code.
  int get renderTextureObjPtr => _rendererPtr.address;

Impact
(A) crashes at FFI lookup on Windows
(B) forces consumers to use unsafe (renderTexture as dynamic) casts

Note: If/when Ticket -> [(https://github.com//issues/610]) resolves (adding nativeTexture to the prebuilt rive_native.dll), issue (A) becomes unnecessary.

Environment
Package: rive_native 0.1.2
Platform: Windows
File: lib/src/rive_native_ffi.dart

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions