Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSI import bug for Android react-native-skottie v2.0.3 #21

Closed
VladyslavMartynov10 opened this issue Jan 25, 2024 · 5 comments
Closed

JSI import bug for Android react-native-skottie v2.0.3 #21

VladyslavMartynov10 opened this issue Jan 25, 2024 · 5 comments
Labels
bug Something isn't working build-system

Comments

@VladyslavMartynov10
Copy link

After installing the latest version 2.0.3, Android gives build error.

image
/node_modules/react-native-skottie/android/../cpp/JsiSkSkottie.h:11:10: fatal error: 'modules/skottie/include/Skottie.h' file not found
  #include <modules/skottie/include/Skottie.h>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It seems that the #include path is incorrect in react-native-skottie/cpp/JsiSkSkottie.h:

 #pragma once

#include <jsi/jsi.h>

#include <JsiSkCanvas.h>
#include <JsiSkHostObjects.h>

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"

#include <modules/skottie/include/Skottie.h> - this line triggers build error

#pragma clang diagnostic pop

namespace RNSkia {
using namespace facebook;

class JsiSkSkottie : public JsiSkWrappingSkPtrHostObject<skottie::Animation> {
public:
  // #region Properties
  JSI_PROPERTY_GET(duration) {
    return static_cast<double>(getObject()->duration());
  }
  JSI_PROPERTY_GET(fps) {
    return static_cast<double>(getObject()->fps());
  }

  JSI_PROPERTY_GET(__typename__) {
    return jsi::String::createFromUtf8(runtime, "Skottie");
  }

  JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkSkottie, duration), JSI_EXPORT_PROP_GET(JsiSkSkottie, fps),
                              JSI_EXPORT_PROP_GET(JsiSkSkottie, __typename__))
  // #endregion

  // #region Methods
  JSI_HOST_FUNCTION(seek) {
    getObject()->seek(arguments[0].asNumber());
    return jsi::Value::undefined();
  }

  JSI_HOST_FUNCTION(render) {
    auto canvas = arguments[0].asObject(runtime).asHostObject<JsiSkCanvas>(runtime)->getCanvas();

    auto rect = JsiSkRect::fromValue(runtime, arguments[1]);
    if (canvas != nullptr && rect != nullptr) {
      getObject()->render(canvas, rect.get());
    }

    return jsi::Value::undefined();
  }

  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkSkottie, seek), JSI_EXPORT_FUNC(JsiSkSkottie, render), JSI_EXPORT_FUNC(JsiSkSkottie, dispose))
  // #endregion

  /**
    Constructor
  */
  JsiSkSkottie(std::shared_ptr<RNSkPlatformContext> context, const sk_sp<skottie::Animation> animation)
      : JsiSkWrappingSkPtrHostObject<skottie::Animation>(std::move(context), std::move(animation)) {}

  /**
    Returns the jsi object from a host object of this type
  */
  static sk_sp<skottie::Animation> fromValue(jsi::Runtime& runtime, const jsi::Value& obj) {
    return obj.asObject(runtime).asHostObject<JsiSkSkottie>(runtime)->getObject();
  }

  /**
   * Creates the function for contructing a new instance of the
   * JsiSkSkottie class.
   *
   * @param context platform context
   * @return A function for creating a new host object wrapper for the JsiSkSkottie class.
   */
  static const jsi::HostFunctionType createCtor(std::shared_ptr<RNSkPlatformContext> context) {
    return JSI_HOST_FUNCTION_LAMBDA {
      auto jsonStr = arguments[0].asString(runtime).utf8(runtime);
      auto animation = skottie::Animation::Builder().make(jsonStr.c_str(), jsonStr.size());

      // Return the newly constructed object
      return jsi::Object::createFromHostObject(runtime, std::make_shared<JsiSkSkottie>(std::move(context), std::move(animation)));
    };
  }
};
} // namespace RNSkia

Package json dependencies:
"@shopify/react-native-skia": "^0.1.233",
"react-native": "0.72.7",
"react-native-skottie": "^2.0.3",

@hannojg
Copy link
Member

hannojg commented Jan 25, 2024

Hey thanks for the report, will look into that soon!

@hannojg hannojg added bug Something isn't working build-system labels Jan 25, 2024
@nurikjohn
Copy link

I am facing this issue too

@hannojg
Copy link
Member

hannojg commented Jan 26, 2024

Hey, please retest with vision 2.0.4, should be fixed 🤞

@SungilJung
Copy link

I am facing this issue too.
"version": "2.1.0",

@hannojg
Copy link
Member

hannojg commented May 5, 2024

Hey, this should definitely be fixed in 2.1.1.
Also the GitHub android build pipelines are working.

Note that the minimum required react native version is >= 0.71.

In case it's still not working, please open a new issue with a reproduction. Thanks!

@hannojg hannojg closed this as completed May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build-system
Projects
None yet
Development

No branches or pull requests

4 participants