Giter Club home page Giter Club logo

Comments (20)

darind avatar darind commented on May 25, 2024 1

@jibon57, I have released some fixes related to workers. Could you please verify if your application still crashes?

from ios.

darind avatar darind commented on May 25, 2024 1

Thanks, I am looking into this problem now.

from ios.

darind avatar darind commented on May 25, 2024 1

@jibon57, we have released a fix for this issue. Now the total score is properly shown when the Stop button is clicked. Could you please check it on your side as well?

from ios.

darind avatar darind commented on May 25, 2024 1

I suspect that this has something to do with the API you are using and not the runtime. Can you verify whether the parameters and headers sent to the endpoint differ somehow? Or maybe something related to the microphone access?

from ios.

jibon57 avatar jibon57 commented on May 25, 2024

Hello,

I am getting this type error in one of project:

Native stack trace:
1          0x10390d2cb tns::Assert(bool, v8::Isolate*) + 119
2          0x103969415 tns::NativeScriptException::OnUncaughtError(v8::Local<v8::Message>, v8::Local<v8::Value>) + 565
3          0x103d5f2b5 v8::internal::MessageHandler::ReportMessageNoExceptions(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::Object>, v8::Local<v8::Value>) + 373
4          0x103d5f0f9 v8::internal::MessageHandler::ReportMessage(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::JSMessageObject>) + 889
5          0x103c76f4a v8::internal::Isolate::ReportPendingMessagesImpl(bool) + 538
6          0x103b8afa2 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) + 2386
7          0x103b8a620 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) + 224
8          0x1039d1dcf v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) + 463
9          0x10387a897 invocation function for block in tns::ArgConverter::MethodCallback(ffi_cif*, void*, void**, void*) + 832
10         0x10387a442 tns::ArgConverter::MethodCallback(ffi_cif*, void*, void**, void*) + 148
11         0x1039ac146 ffi_closure_unix64_inner + 662
12         0x1039ad3ca ffi_closure_unix64 + 72
13         0x104cfc511 -[SDWebImageDownloaderOperation URLSession:dataTask:didReceiveData:] + 2689
14         0x104cf6191 -[SDWebImageDownloader URLSession:dataTask:didReceiveData:] + 209
15      0x7fff22e9bb7b _CFNetworkHTTPConnectionCacheSetLimit + 205307
16      0x7fff2567de0f __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
17      0x7fff2567dd07 -[NSBlockOperation main] + 98
18      0x7fff25680c94 __NSOPERATION_IS_INVOKING_MAIN__ + 17
19      0x7fff2567cf07 -[NSOperation start] + 731
20      0x7fff256815ee __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 17
21      0x7fff256810f8 __NSOQSchedule_f + 182
22      0x7fff516ba274 _dispatch_block_async_invoke2 + 83
23      0x7fff516ad781 _dispatch_client_callout + 8
24      0x7fff516afb3d _dispatch_continuation_pop + 440
25      0x7fff516af209 _dispatch_async_redirect_invoke + 817
26      0x7fff516bcbfc _dispatch_root_queue_drain + 350
27      0x7fff516bd39e _dispatch_worker_thread2 + 99
28      0x7fff518d16b6 _pthread_wqthread + 220
29      0x7fff518d0827 start_wqthread + 15
JavaScript stack trace:

voiceEvaluation.worker.ts

import "tns-core-modules/globals";
import { request } from "tns-core-modules/http";
import * as app from "tns-core-modules/application";
import { File, knownFolders, path } from 'tns-core-modules/file-system';
import { MD5 } from "nativescript-md5";
import { alert } from "tns-core-modules/ui/dialogs/dialogs";

const context: Worker = self as any;
declare var android, java, jaygoo, NSString, NSUTF8StringEncoding;

context.onmessage = msg => {

    let recordFile
    if (app.android) {
        recordFile = knownFolders.temp().path + "/recordedFile.pcm";

    } else {
        recordFile = knownFolders.temp().path + "/recordedFile.caf";
    }

    console.log("worker file: ", recordFile);

    let base64File = this.getBase64String(recordFile);

    if (app.android) {
        // convert mp3
        let Mp3Converter = jaygoo.library.converter.Mp3Converter;
        let mp3path = knownFolders.temp().path + "/recordedFile.mp3";
        Mp3Converter.init(8000, 2, 0, 8000, 96, 7);
        Mp3Converter.convertMp3(recordFile, mp3path);
    }

    sendFileForEvaluation(base64File, msg.data);
};

export function getBase64String(file) {

    const recordedFile: File = File.fromPath(file);
    const data = recordedFile.readSync();

    if (app.ios) {
        return data.base64EncodedStringWithOptions(0);
    }
    if (app.android) {
        return android.util.Base64.encodeToString(data, android.util.Base64.NO_WRAP);
    }
}

/**
 * getBase64Text
 */
export function getBase64Param(Params) {
    let json = JSON.stringify(Params);

    if (app.android) {
        const text = new java.lang.String(json);
        const data = text.getBytes("UTF-8");
        return android.util.Base64.encodeToString(data, android.util.Base64.NO_WRAP);
    } else {
        const text = NSString.stringWithString(json);
        const data = text.dataUsingEncoding(NSUTF8StringEncoding);
        return data.base64EncodedStringWithOptions(0);
    }
}

/**
  * sendFileForEvaluation
  */
export function sendFileForEvaluation(audioBase64, text) {


}

from ios.

darind avatar darind commented on May 25, 2024

@jibon57, it seems that some error is thrown while evaluating the worker script. The onerror callback should be invoked in this case and might provide more details:

context.onerror = err => { 
    console.log(err);
    return false;
};

One interesting line is the following:

let base64File = this.getBase64String(recordFile);

I suspect that the issue here is that this might be undefined or might not have the getBase64String method defined on it. Can you share the transpiled javascript code from your worker?

from ios.

jibon57 avatar jibon57 commented on May 25, 2024

Thanks for reply. Here is the javascript code

"use strict";
/* WEBPACK VAR INJECTION */(function(global) {
Object.defineProperty(exports, "__esModule", { value: true });
__webpack_require__("../node_modules/@nativescript/core/globals/globals.js");
var http_1 = __webpack_require__("../node_modules/@nativescript/core/http/http.js");
var app = __webpack_require__("../node_modules/@nativescript/core/application/application.js");
var file_system_1 = __webpack_require__("../node_modules/@nativescript/core/file-system/file-system.js");
var nativescript_md5_1 = __webpack_require__("../node_modules/nativescript-md5/md5.js");
var dialogs_1 = __webpack_require__("../node_modules/@nativescript/core/ui/dialogs/dialogs.js");
var context = self;
context.onmessage = function (msg) {
    var recordFile;
    if (app.android) {
        recordFile = file_system_1.knownFolders.temp().path + "/recordedFile.pcm";
    }
    else {
        recordFile = file_system_1.knownFolders.temp().path + "/recordedFile.caf";
    }
    console.log("worker file: ", recordFile);
    var base64File = getBase64String(recordFile);
    if (app.android) {
        // convert mp3
        var Mp3Converter = jaygoo.library.converter.Mp3Converter;
        var mp3path = file_system_1.knownFolders.temp().path + "/recordedFile.mp3";
        Mp3Converter.init(8000, 2, 0, 8000, 96, 7);
        Mp3Converter.convertMp3(recordFile, mp3path);
    }
    sendFileForEvaluation(base64File, msg.data);
};
context.onerror = function (err) {
    console.log(err);
    return false;
};
function getBase64String(file) {
    var recordedFile = file_system_1.File.fromPath(file);
    var data = recordedFile.readSync();
    if (app.ios) {
        return data.base64EncodedStringWithOptions(0);
    }
    if (app.android) {
        return android.util.Base64.encodeToString(data, android.util.Base64.NO_WRAP);
    }
}
exports.getBase64String = getBase64String;
/**
 * getBase64Text
 */
function getBase64Param(Params) {
    var json = JSON.stringify(Params);
    if (app.android) {
        var text = new java.lang.String(json);
        var data = text.getBytes("UTF-8");
        return android.util.Base64.encodeToString(data, android.util.Base64.NO_WRAP);
    }
    else {
        var text = NSString.stringWithString(json);
        var data = text.dataUsingEncoding(NSUTF8StringEncoding);
        return data.base64EncodedStringWithOptions(0);
    }
}
exports.getBase64Param = getBase64Param;
/**
  * sendFileForEvaluation
  */
function sendFileForEvaluation(audioBase64, text) {
    var d = new Date();
    var XCurTime = Math.round(d.getTime() / 1000).toString();
    var url = "https://api.example.com";
    var XAppid = "";
    var Apikey = "";
    var Param = {
        "aue": "raw",
        "result_level": "entirety",
        "language": "en_us",
        "category": "read_sentence"
    };
    var XParam = getBase64Param(Param);
    var XCheckSum = nativescript_md5_1.MD5.hashForString(Apikey + XCurTime + XParam);
    var headers = {
        'X-CurTime': XCurTime,
        "X-Param": XParam,
        "X-Appid": XAppid,
        "X-CheckSum": XCheckSum,
        "Content-Type": 'application/x-www-form-urlencoded; charset=utf-8',
    };
    var body = new FormData();
    body.append('audio', audioBase64);
    body.append('text', text);
    http_1.request({
        url: url,
        method: "POST",
        headers: headers,
        content: body
    }).then(function (response) {
        var data = response.content.toJSON();
        console.dir(data);
        console.log("total_score", data.data.read_sentence.rec_paper.read_chapter.total_score);
        global.postMessage(data.data.read_sentence.rec_paper.read_chapter.total_score);
        close();
    }, function (e) {
        console.dir(e);
        dialogs_1.alert(JSON.stringify(e));
        global.postMessage("error");
        close();
    });
}
exports.sendFileForEvaluation = sendFileForEvaluation;

/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("../node_modules/webpack/buildin/global.js")))

from ios.

darind avatar darind commented on May 25, 2024

@jibon57, do you get the console.dir(data); call inside the success callback of your HTTP request? Is the onerror method called (if yes, with what parameter)?

from ios.

jibon57 avatar jibon57 commented on May 25, 2024

@darind I have sent you my project by email.

from ios.

darind avatar darind commented on May 25, 2024

@jibon57, I am having some issues building your project. It seems that it depends on some plugins that are not available (@nstudio/nativescript-loading-indicator).

Also I am getting the following error when building:

ERROR in ./workers/voiceEvaluation.worker.ts (../node_modules/nativescript-dev-webpack/moduleid-compat-loader.js!../node_modules/nativescript-dev-webpack/lazy-ngmodule-hot-loader.js!../node_modules/@ngtools/webpack/src!./workers/voiceEvaluation.worker.ts)
    Module build failed (from ../node_modules/@ngtools/webpack/src/index.js):
    Error: The AngularCompilerPlugin was not found. The @ngtools/webpack loader requires the plugin.
        at Object.ngcLoader 

from ios.

jibon57 avatar jibon57 commented on May 25, 2024

Sorry, I am using another location version. During sending to you I removed that one. Here the one I was using for nativescript-loading-indicator

Archive.zip

from ios.

darind avatar darind commented on May 25, 2024

okay, still remaining the issue with workers/voiceEvaluation.worker.ts:

ERROR in ./workers/voiceEvaluation.worker.ts (../node_modules/nativescript-dev-webpack/moduleid-compat-loader.js!../node_modules/nativescript-dev-webpack/lazy-ngmodule-hot-loader.js!../node_modules/@ngtools/webpack/src!./workers/voiceEvaluation.worker.ts)
Module build failed (from ../node_modules/@ngtools/webpack/src/index.js):
Error: The AngularCompilerPlugin was not found. The @ngtools/webpack loader requires the plugin.
    at Object.ngcLoader (/Users/<username>/nativescript/<project_name>/node_modules/@ngtools/webpack/src/loader.js:27:15)
Executing webpack failed with exit code 2.

from ios.

jibon57 avatar jibon57 commented on May 25, 2024

Sorry, I am sending again by email

from ios.

jibon57 avatar jibon57 commented on May 25, 2024

@darind also I am always getting invalid parameter|invalid Headprams error message. If you'll test with default ios runtime then you will get success message with score.

from ios.

jibon57 avatar jibon57 commented on May 25, 2024

@darind thanks. I have noticed if I call close() method after call postMessage in worker then it won't postMessage anything. What will be correct way to call that? You can check my code from project. But if you try using default runtime then it will work.

from ios.

jibon57 avatar jibon57 commented on May 25, 2024

@darind thank you! Yes, this time I didn't get any of above problem. But the recording score is always 0. Basically you will have to read & record the text those are showing. After click on stop button you will get the score based on your pronunciation but I am always getting 0. I did same test using default runtime & getting success (at least some score)

from ios.

jibon57 avatar jibon57 commented on May 25, 2024

@darind I just tested from a real device & it's getting score. From simulator I was always getting 0 :D

from ios.

darind avatar darind commented on May 25, 2024

@jibon57, I've just tried your app with the official iOS runtime and I am also getting 0 score when running on the Simulator. Are you sure you are getting non-zero score on the simulator with the official runtime?

from ios.

jibon57 avatar jibon57 commented on May 25, 2024

Simulator Screen Shot - iPhone 11 - 2020-02-05 at 23 52 28

from ios.

jibon57 avatar jibon57 commented on May 25, 2024

@darind thanks. Yes, may be problem from provider as that from China & from outside of China connection is always bad. Thank you so much for your all help :) ..

from ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.