rive-app / rive-app/rive-flutter

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

Open
#612 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dart
Stars
1.5k
Forks
240
PR merge metrics
No merged PRs in 30d

Description

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/rive-app/rive-flutter/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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/src/rive_native_ffi.dart by tracing _nativeTexture through DynamicLibraryHelper.nativeLib and inspecting _NativeRenderTexture. Verify the Windows lookup targets the plugin DLL while other platforms retain their existing library, and confirm the renderer pointer can be exposed as an integer address for method-channel consumers.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
desktop-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.