No way to know when ViewModelImageProperty.set() has been applied (listener is a no-op on the new backend)

Đang mở
#445 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
44/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react-native, typescript
Lĩnh vực
backend, mobile

Hướng nghiên cứu

Start by tracing ViewModelImageProperty.set() and addListener() in the React Native package, then inspect the Android and iOS backend implementations mentioned in the issue. Compare how image writes are applied with number and string writes, and check the existing view readiness and frame APIs. Done means providing a reliable signal after a bound write is applied or drawn, with coverage for the reported paused-view behavior.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

android bug enhancement iOS

Versions: @rive-app/react-native 0.5.10 (rive-android 11.14.3, rive-ios 6.29.0), new backend, React Native 0.86. Seen on a Pixel 9 Pro XL.

Problem

Since 0.5.8, imageProperty.set(image) decodes the image asynchronously and applies it later, which fixed the memory growth. But JS has no way to know when the image is actually applied and drawn:

  • ViewModelImageProperty.addListener() is a no-op on the new backend, on both Android ("Image property listeners not supported in experimental API") and iOS (TODO: image property listener not yet available in concurrency API).
  • set() returns void, not a promise.
Why it matters

We show a static <Image> of an artwork, then hand over to a RiveView that draws the same artwork through an image property. Without a signal, the handover has to be a fixed timer:

  • If we swap too early, the Rive view is visible but hasn't drawn the image yet, so it blinks empty. On a Pixel 9 Pro XL the image lands about 450 ms after awaitViewReady() resolves.
  • If we swap too late, the view sits still before its animation starts.
  • Views we pause() after a short paint window stay empty for good if the image lands after the pause, because a paused view isn't redrawn.

Number and string writes have the same gap: a view revealed right after stringProperty.set() plus a trigger draws the artboard's baked placeholder for about 0.5 s on Android before the write lands.

Repro
  1. Load a file with an image property and create a view model instance.
  2. Mount a RiveView bound to it, and call imageProperty.set(image) with a RiveImage from RiveImages.loadFromURLAsync.
  3. Show the view as soon as awaitViewReady() resolves: it draws without the image for several hundred ms.
  4. Or call pause() about 250 ms after ready: the image never appears until playIfNeeded().
Request

Any one of these would work:

  1. Make ViewModelImageProperty.addListener() fire once a set has been applied.
  2. Have set() return a Promise<void> that resolves when the value is applied, or better, after the next frame that includes it.
  3. A view-level signal such as onFrameDrawn or awaitNextFrame() after pending data-binding writes have been processed.
  4. Have a paused view redraw once when a bound image or property changes, so a parked view doesn't stay stale.
Related

Since 0.5.8, a newer set() on the same property cancels one still decoding (the generation counter). That's correct, but setting the same image twice, for example once before the view binds and again after awaitViewReady(), throws away the first decode and delays the image further.

Ngôn ngữ chính
TypeScript
Star
158
Fork
17
Merge trung bình
4 ngày 4 giờ
Pull request đã merge (30 ngày)
23

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rive-app/rive-nitro-react-native

Tất cả issue của rive-app/rive-nitro-react-native

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.