capture-vision-react-native-samples icon indicating copy to clipboard operation
capture-vision-react-native-samples copied to clipboard

CALayerInvalidGeometry in DMEditorView.m

Open julopez10 opened this issue 1 month ago • 3 comments

Error:

CALayer position contains NaN: [nan 389]. Layer: <CALayer:0x10e7f38a0; position = CGPoint (0 0); bounds = CGRect (0 0; 0 0); delegate = <DMTouchAreaView: 0x10e7e5e00; frame = (0 0; 0 0); gestureRecognizers = <NSArray: 0x10e567e20>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x10e7f38a0>>; sublayers = (<CALayer: 0x10e7f39c0>, <CALayer: 0x10e54a610>, <CALayer: 0x10e7bd6b0>, <CALayer: 0x10e7bf090>, <CALayer: 0x116c378a0>, <CALayer: 0x10e6e30c0>, <CALayer: 0x10e7bcff0>, <CALayer: 0x10e7bd6e0>, <CAShapeLayer: 0x10e6e3f90>); allowsGroupOpacity = YES; backgroundColor = <CGColor 0x10b668d20> [<CGColorSpace 0x10b6680c0> (kCGColorSpaceICCBased; kCGColorSpaceModelMonochrome; Generic Gray Gamma 2.2 Profile; extended range)] ( 0 0 )>

Libraries: "react": "18.3.1" "react-native": "0.76.9" "dynamsoft-capture-vision-react-native": 2.6.1016

Currently this issue affects iPhone 17 Pro model. (Not sure if other iPhones are also affected). Works fine for Android.

julopez10 avatar Nov 14 '25 04:11 julopez10

Hello, we apologize for the late reply on this issue. Can you please confirm which of the functional products of Dynamsoft you are currently using? Is it the Barcode Reader, MRZ Scanner, or the Document Normalizer?

As for this issue, is there a specific line or code snippet that is triggering the error? If you are not sure, would it be possible that you share your current code with us so that we inspect the Dynamsoft-related parts and reproduce the issue?

Another thing to note: You are currently using an older version of the dynamsoft-capture-vision-react-native library - the current version is 3.0.5201. There have been fixes and tweak done to the iOS framework that is part of the dynamsoft-capture-vision-react-native library since v2.6.1016 so one of the things that we currently recommend is to upgrade to the latest version in order to make use of these fixes.

If you would like to have a more consistent dialogue regarding this issue - please contact us at [email protected]. Or if you would like to have a live chat, please visit https://www.dynamsoft.com/contact/.

amro-dynamsoft avatar Nov 18 '25 21:11 amro-dynamsoft

Image

Was using the Document Normalizer, and just integrated this to our app (with only minor style changes) https://github.com/Dynamsoft/capture-vision-react-native-samples/tree/a32f5665e7da5dbd0303ddf9b9b4fe0a0dd149c5/DetectAndDeskewDocument/src

Reason why we were using v2.6.1016 instead of the new version(3.0.5201) is that there was an error compiling in Expo.

I just upgraded to Expo 53 (using RN v.79 and React v19) and still have this error.

EDIT: I was able to build successfully using v2.6.1016

julopez10 avatar Nov 19 '25 09:11 julopez10

Hello,

So as I understand it - you are encountering a build.gradle error when using Expo in your project. Can you please confirm the version of Gradle that you are using in your app? I believe that it will require v8.x when using Expo since there are some deprecated features in Gradle v9.x that are required by Expo.

I just tested the ScanDocument sample in an Expo environment, and was able to get it to work after making some changes to the build.gradle. Here is the code for the full build.gradle in the android folder of dynamsoft-capture-vision-react-native.

def DEFAULT_COMPILE_SDK_VERSION = 34
def DEFAULT_MIN_SDK_VERSION = 21
def DEFAULT_TARGET_SDK_VERSION = 34

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: 'com.android.library'
apply plugin: "kotlin-android"

buildscript {
    def kotlinVersion = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["kotlinVersion"]
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.5.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

static def supportsNamespace() {
    def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
    def major = parsed[0].toInteger()
    def minor = parsed[1].toInteger()
    return (major == 7 && minor >= 3) || major >= 8
}


def getReactNativeVersion() {
    def packageJsonFile = file("$rootDir/../node_modules/react-native/package.json")
    if (packageJsonFile.exists()) {
        def packageJson = new groovy.json.JsonSlurper().parseText(packageJsonFile.text)
        return packageJson.version
    }
    return "unknown"
}

static def getMajor(String version) {
    def parts = version.tokenize('.')
    return parts.size() > 0 ? parts[0].toInteger() : 0
}

static def getMinor(String version) {
    def parts = version.tokenize('.')
    return parts.size() > 1 ? parts[1].toInteger() : 0
}

android {
    def reactNativeVersion = getReactNativeVersion()
    def versionNumber = getMajor(reactNativeVersion) * 100 + getMinor(reactNativeVersion)

    if (supportsNamespace()) {
        namespace "com.dynamsoft.reactnativelib"
        sourceSets {
            main {
                manifest.srcFile "src/main/AndroidManifest_noPackage.xml"
            }
        }
    }

    compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
        targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
        versionCode 1
        versionName "1.0"

        if (versionNumber < 79) {
            externalNativeBuild {
                cmake {
                    arguments "-DANDROID_STL=c++_shared"
                }
            }
        }
    }
    lintOptions {
        abortOnError false
    }

    if (versionNumber < 79) {
        buildFeatures {
            prefab true
            buildConfig true
        }
        externalNativeBuild {
            cmake {
                path "src/main/cpp/CMakeLists.txt"
            }
        }
    } else {
        buildTypes {
            release {
                sourceSets {
                    main {
                        if (versionNumber >= 82) {
                            jniLibs.srcDirs = ["src/main/dysJniLibsFor82/release"]
                        } else if (versionNumber >= 81) {
                            jniLibs.srcDirs = ["src/main/dysJniLibsFor81/release"]
                        } else {
                            jniLibs.srcDirs = ["src/main/dysJniLibs/release"]
                        }
                    }
                }
            }
            debug {
                sourceSets {
                    main {
                        if (versionNumber >= 82) {
                            jniLibs.srcDirs = ["src/main/dysJniLibsFor82/debug"]
                        } else if (versionNumber >= 81) {
                            jniLibs.srcDirs = ["src/main/dysJniLibsFor81/debug"]
                        } else {
                            jniLibs.srcDirs = ["src/main/dysJniLibs/debug"]
                        }
                    }
                }
            }
        }
    }

}

repositories {
    google()
    mavenCentral()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
    maven {
        // Android JSC is installed from npm
        url "$rootDir/../node_modules/jsc-android/dist"
    }
}

rootProject.allprojects {
    repositories {
        maven {
            url "https://download2.dynamsoft.com/maven/aar"
        }
    }

    configurations.configureEach {
        if (!it.state.name().equals("RESOLVED") && !it.state.name().equals("RESOLVING")) {
            resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
        }
    }
}


dependencies {
    def kotlinVersion = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["kotlinVersion"]

    //noinspection GradleDynamicVersion
    implementation 'com.facebook.react:react-native:+'
    compileOnly "com.facebook.react:react-android:+"

    //noinspection GradleDependency

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"

    implementation "com.dynamsoft:capturevisionbundle:3.0.5000"
}

The main changes I did to build.gradle in order to get it to successfully build and run:

  • Fixed the Gradle configuration error in the Dynamsoft library
  • Added the Dynamsoft Maven repo

After doing that, the app was finally able to successfully build and run in my Expo project. (The app cannot run via Expo Go since the dynamsoft-capture-vision-react-native-library is a native component and requires to be run as a "traditional" React Native library.

If you would like the full Expo project that I am using so you can use it as reference - please contact the support team at [email protected] and have a reference to this issue and ask for me (Amro) so that I can be cc'd.

I hope that this helps but please let us know if you are still encountering issues and we can work to resolve them.

amro-dynamsoft avatar Nov 21 '25 00:11 amro-dynamsoft