platform/core/api/webapi-plugins.git
4 months ago[Archive] Fixed permission handling for windows-zipped files 52/302652/1 tizen_6.5
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Mon, 11 Dec 2023 10:51:01 +0000 (11:51 +0100)]
[Archive] Fixed permission handling for windows-zipped files

[Issue] When having files with added P attribute on windows, then zipped
and unzipped on tizen using Web API, files have invalid access rights.

Reproduction:
1. create file on windows
2. add P attribute: attrib -a +p test_file.txt
3. zip file with 7-zip
4. copy to tizen device and unzip with webapi:
function errorCallback(error) {console.log(error);}
function successCallback() {console.log("done");}
function progressCallback(opId, val, name) {
  console.log(
      "extracting operation (: " + opId + ") is in progress (" + (val * 100).toFixed(1) + "%)");
}
function openSuccess(archive) {
  archive.extractAll("downloads", successCallback, errorCallback, progressCallback);
}
tizen.archive.open("downloads/test_kona.zip", "r", openSuccess);
5. check file permission:
 ------x--- 1 owner priv_mediastorage User::App::Shared 9 Oct 31 14:07 testfile.txt

[Verification] With this commit, above scenario ends with proper 755
permissions (for windows files), and recreated files permissions if
points 1-3 are done on ubuntu.
TCT passrate is 100%.

Change-Id: I8d6e3de036b39f5180b4773eaee5b710b0def9be
(cherry picked from commit 0985b4c8da445e34f517cfa63d94a82f00deabb5)

9 months agoFixed listDirectory() 35/296035/1
p.kosko@samsung.com [Tue, 18 Jul 2023 12:13:05 +0000 (14:13 +0200)]
Fixed listDirectory()

[KONA] DF230714-00592

Issue: names returned via API can be invalid.
1. create many files in dir, 1-100.txt files
2. tizen.filesystem.listDirectory("documents", function(files) {f = files; console.log(files) }, function(e) { console.log(e) } )

issued list contains empty names/names with strange characters.

This fixes above problems.

[Verification] With above code, problem doesn't occur.
TCT passrate 100%.

Change-Id: Ief9ec91b0a130d789c8777423f51dfa6b2f6de9d

10 months ago[Keymanager] Fix alias tokenizing 44/294444/1 accepted/tizen_6.5_unified accepted/tizen/6.5/unified/20230621.125857
Krzysztof Jackiewicz [Mon, 19 Jun 2023 07:34:16 +0000 (09:34 +0200)]
[Keymanager] Fix alias tokenizing

There are 2 problems with key-manager alias tokenizing code:
1. strtok_r() used for tokenizing affects internal/opaque key-manager's
   structure ckmc_alias_info_s by modifying the string pointed by the
   pointer returned from ckmc_alias_info_get_alias(). As a result, the
   following call to ckmc_alias_info_is_password_protected(), that uses
   this structure, fails.
2. strtok_r() splits the string when *any* of characters passed in
   'delim' argument is found. However, the ckmc_owner_id_separator is
   in fact a string, not a set of delimiting characters. It's current
   value is ' ' which happens to work well with strtok_r() but this is
   also a part of internal key-manager's code and may be changed in
   future.

Fix above by locating a complete ckmc_owner_id_separator substring and
tokenizing it without modifying the original string.

Change-Id: I86a4dcbb36dad98219acf32a69d9bbb4164c83b4

19 months ago[Download] Fixed download initialization 89/281389/1
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Thu, 15 Sep 2022 10:41:42 +0000 (12:41 +0200)]
[Download] Fixed download initialization

When many downloads are taking place one after another it was possible
that uninitialized memory used for state value has a 5,6,7 status, which
caused that web api interpreted it as not valid state change, when the
'DOWNLOADING' state comes. Now this should not occur as the state is
initialized before starting a download.

Change-Id: I8c0ed0d375e512c1dcc17255f2387df70f3ddcb3
(cherry picked from commit 722a53ccbd76726cb84f65f60c3ba98b0cbb2208)

20 months ago[Filesystem] Fixed invalid unregistration of StateListener 31/280331/1
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Fri, 26 Aug 2022 13:24:50 +0000 (15:24 +0200)]
[Filesystem] Fixed invalid unregistration of StateListener

Issue occurred when running filesystem manual TCTs, first test passed,
the second test didn't pass because static FilesystemManager didn't
unregister the listener properly.

[Verification]
Filesystem manual TCT passed.
Filesystem auto 100% pass.

Change-Id: I185f541b15c146c3b62fb1dbfd5df48c0a9dd5e4

2 years ago[Common] Changed method of deviced listener implementation 20/272320/1
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Mon, 14 Mar 2022 10:46:24 +0000 (11:46 +0100)]
[Common] Changed method of deviced listener implementation

To prevent crash in multithreaded model of wrt-services, there is a need
to use device_changed_callback_ as a thread local variable.

[Verification] Code compiles without errors.

Change-Id: Ifba2cef597e6244ab9c071b10c870b942b500946

2 years agoRevert "Use thread_local (instead of static) storage duration due to thread safety... 19/272319/1
DongHyun Song [Mon, 14 Mar 2022 02:06:39 +0000 (02:06 +0000)]
Revert "Use thread_local (instead of static) storage duration due to thread safety issue."

This reverts commit 122bae587fb3d4d1879f567baa97b72bdd6a1a5a.

Change-Id: Ic2ff664d602044b400c48063285039ded3472af9
(cherry picked from commit de39ed39f8e75afb9718f242069614646d08c26c)

2 years agoAdd 'self' as global scope for web worker 75/272175/1
DongHyun Song [Tue, 8 Mar 2022 08:35:55 +0000 (17:35 +0900)]
Add 'self' as global scope for web worker

In web worker world, 'self' is defined global scope object.
This change is necessary to apply tizen webapis on web worker for
specific purpose. (i.e. tizen.ml)

Change-Id: Ie9602ea4f492589dad2c87e3c0bd8e2602278c02
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
(cherry picked from commit 937fc3e4fd8c9a3dd32974a4e261d82e4db31b73)

2 years agoUse thread_local (instead of static) storage duration due to thread safety issue. 71/272171/1
Marcin Bialek [Mon, 8 Nov 2021 12:19:28 +0000 (13:19 +0100)]
Use thread_local (instead of static) storage duration due to thread safety issue.

Similar issue: 605574a932c7ddac63bb394d520178d332ed05dc

[Verification] TCT tests and a sample application.

Change-Id: I988fb82763999751ce56d77847013506fea5875c
(cherry picked from commit 122bae587fb3d4d1879f567baa97b72bdd6a1a5a)

2 years ago[Archive] Support for global paths in tizen.archive methods 65/270765/1
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Thu, 27 Jan 2022 19:04:25 +0000 (20:04 +0100)]
[Archive] Support for global paths in tizen.archive methods

[ACR] https://code.sec.samsung.net/jira/browse/TWDAPI-286

[TCT] 5 failures - TCT need to be updated.

Change-Id: Ibdbf1c48468bb0648c2dd107cc2f42b506fe73df

2 years ago[Messaging] Prevent crash of using released structure mail_data_final 16/268816/1 accepted/tizen/6.5/unified/20220117.134841 submit/tizen_6.5/20220113.125456
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Fri, 24 Dec 2021 09:38:57 +0000 (10:38 +0100)]
[Messaging] Prevent crash of using released structure mail_data_final

In line 296, there is the usage:
  mail_data_final->thread_id = mail_data_final->mail_id;

but if retries loop above reaches limit, then the structure is relased,
so using it causes crash.
To prevent it, we release data on the beginning of the next iteration of
a loop.

[Verification] TCT passrate:
messaging-email - 100%.

Change-Id: I4751e5509271f28ab803e0ef10a90ff10d61ec10

2 years ago[version] 2.88 44/264544/1 accepted/tizen/6.5/unified/20211028.095124 accepted/tizen/unified/20210926.235712 submit/tizen/20210924.083751 submit/tizen_6.5/20211028.161801 tizen_6.5.m2_release
Pawel Wasowski [Fri, 24 Sep 2021 08:07:15 +0000 (10:07 +0200)]
[version] 2.88

Change-Id: I7ebf1b81237f2e9bd3dae16cc16bb3d1fad266d1
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
2 years ago[ML][Single] Fix the crash issue in single API 43/264543/1
Sangjung Woo [Fri, 24 Sep 2021 07:38:09 +0000 (16:38 +0900)]
[ML][Single] Fix the crash issue in single API

Before closing the singleshot handle, the output tensor data is freed.
Since inference internally is going on, this situation could cause the
segmentation fault in sub-plugin part. This patch fixes that bug.

Change-Id: I690b4ef941e981353f3809cc56a1f2089ef2a4e5
Signed-off-by: Sangjung Woo <sangjung.woo@samsung.com>
2 years agoMerge "[Playerutil] Removed dependency to EWK by using XWALK Extension" into tizen accepted/tizen/unified/20210914.135033 submit/tizen/20210914.065046
Piotr Kosko [Fri, 10 Sep 2021 07:19:33 +0000 (07:19 +0000)]
Merge "[Playerutil] Removed dependency to EWK by using XWALK Extension" into tizen

2 years agoMerge "[common] Use thread_local (instead of static) objects for access checks" into...
Piotr Kosko [Fri, 10 Sep 2021 07:18:54 +0000 (07:18 +0000)]
Merge "[common] Use thread_local (instead of static) objects for access checks" into tizen

2 years ago[Playerutil] Removed dependency to EWK by using XWALK Extension 61/263761/1
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Thu, 9 Sep 2021 12:18:16 +0000 (14:18 +0200)]
[Playerutil] Removed dependency to EWK by using XWALK Extension

Related native change:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/249379/

Change-Id: Ie1088d64b84b9f2087be20531e6852d62f754f21

2 years ago[common] Use thread_local (instead of static) objects for access checks 67/263367/3
Pawel Wasowski [Wed, 1 Sep 2021 07:10:42 +0000 (09:10 +0200)]
[common] Use thread_local (instead of static) objects for access checks

Beginning with Tizen 6.5, a new web service app model has been
introduced. Each service is now a thread of the "master" service
process, instead of having the whole process for its disposal, as it
used to be earlier.
To control privileges of particular services, we need to initialize
the cynara and related objects for each thread separately. Thus we
make them thread_local (one instance per thread) instead of static
(one instance per process).
Similarily, we make RequestStoragePrivilegeChecker thread_local,
so that each app will create its own instance of such object.

[Verification] The code was tested manually in a web service app.
Before this commit, all web services were using the same smack label to
initialize cynara object (the label of the thread that first
initialized the static objects).
Now, each thread initializes cynara with its own smack label.
Each thread uses separate RequestStoragePrivilegeChecker.

Change-Id: I5e6ffae05ed12e60d09c23fdbdc462a6022e926b
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
2 years agoMerge "Add CreateTaskQueue for early initialization" into tizen
Piotr Kosko [Thu, 9 Sep 2021 07:56:37 +0000 (07:56 +0000)]
Merge "Add CreateTaskQueue for early initialization" into tizen

2 years agoMerge "[ml] Add customRequirement to tizen.ml.checkNNFWAvailability" into tizen
Piotr Kosko [Thu, 9 Sep 2021 06:40:27 +0000 (06:40 +0000)]
Merge "[ml] Add customRequirement to tizen.ml.checkNNFWAvailability" into tizen

2 years agoAdd CreateTaskQueue for early initialization 57/263457/2
DongHyun Song [Fri, 3 Sep 2021 01:50:24 +0000 (10:50 +0900)]
Add CreateTaskQueue for early initialization

This API will be used by global wrt-service (thread model)
This singleton TaskQueue instance should have smack label same as
pid's smack label.
After a service app is launched, this TaskQueue thread has app's
smack label. Then, smack violation might be happened.
Thus, to initialize early before app creation, this patch exposes
CreateTaskQueue() funtion for WebRuntime.

Change-Id: I108bed31dbf0dbd1b54a6781530b95618584b0f8
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
2 years ago[version] 2.87 74/263374/1 accepted/tizen/unified/20210907.121804 submit/tizen/20210901.122723 submit/tizen/20210903.060406 submit/tizen/20210906.105006 submit/tizen/20210907.064702
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Wed, 1 Sep 2021 09:38:07 +0000 (11:38 +0200)]
[version] 2.87

Change-Id: Icf0e0e40ade36eda7af543472d4dbe2e96b8ec78

2 years ago[ML] Added binary communication in getTensorRawData() 10/263110/7
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Thu, 26 Aug 2021 07:53:19 +0000 (09:53 +0200)]
[ML] Added binary communication in getTensorRawData()

[Verification]
TCT passrate for tct-ml, tct-mlpipeline and tct-single 100% passrate

Performance results tested with below scenario for
224x224x3 tensor size (TM1 device):

var tries = 100;
var sum = 0;
var tensorsInfo = new tizen.ml.TensorsInfo();
tensorsInfo.addTensorInfo("tensor", "UINT8", [224, 224, 3]);
var tensorsData = tensorsInfo.getTensorsData();
var start = new Date();
tensorsData.setTensorRawData(0, rgb);

for (var i = 0; i < tries; ++i) {
    var start = new Date();
    tensorsData.getTensorRawData(0)
    var end = new Date();
    sum += end-start;
}
console.log ("Average time is: " + (sum / tries) );

BEFORE: Average time is: 139.53
AFTER: Average time is: 5.93

Change-Id: I47f369319744e64c3bd961eb7dda4ad8823b1494
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
Signed-off-by: Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
2 years ago[ml] Add customRequirement to tizen.ml.checkNNFWAvailability 66/263366/1
Pawel Wasowski [Tue, 31 Aug 2021 12:24:44 +0000 (14:24 +0200)]
[ml] Add customRequirement to tizen.ml.checkNNFWAvailability

ACR: TWDAPI-282

[Verification] Tested on TM1 in Chrome DevTools with the snippets below

tizen.ml.checkNNFWAvailability("TENSORFLOW_LITE", "CPU") // true

tizen.ml.checkNNFWAvailability("TENSORFLOW_LITE", "CPU",
                               'test custom requirement'); // true

The native implementation is not ready and returns the same value
whether the customRequirement is passed or not. That's why
tizen.ml.checkNNFWAvailability also returns "true" twice above

Change-Id: I971a5f49d4ea389ad953c28fc08da21bafb59ee2
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
2 years ago[Common] Add synchronization to privilege checking 19/262919/1
Pawel Wasowski [Mon, 23 Aug 2021 14:07:59 +0000 (16:07 +0200)]
[Common] Add synchronization to privilege checking

common::tools::CheckAccess() can be called from multiple threads in the
same time. (This happens in web service apps, which now are running as
separate threads of a single process.)
This commit adds synchronization of the access of this function's static
resources.

[Verification] Code compiles. The code works fine in a single-threaded
app

Change-Id: I4af0715d3605284bf82b2abe207dabe024986d25
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
2 years ago[version] 2.86 81/262881/1 accepted/tizen/unified/20210823.124206 submit/tizen/20210823.074335
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Mon, 23 Aug 2021 05:05:05 +0000 (07:05 +0200)]
[version] 2.86

Change-Id: I6374110425bcd28f1faba2ae44574d629314268a

2 years ago[Iotcon] Add NotSupportedError to initialize() 30/262230/5
Pawel Wasowski [Wed, 4 Aug 2021 16:16:42 +0000 (18:16 +0200)]
[Iotcon] Add NotSupportedError to initialize()

ACR: TWDAPI-279

[Verification] After disabling iotcon support in
/etc/config/model-config.xml, tizen.iotcon.initialize() throws
NotSupportedError, as expected.
Auto tct-iotcon-tizen-tests pass rate: 100% (with the iotcon support
enabled in model-config.xml)
No tct-iotcon-tizen-tests are run when the iotcon support is disabled
in model-config.xml

Change-Id: I41be8376bcc1bca5b919daa0a5d0a9651b14d335
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
2 years agoMerge "[Common] Added caching custom virutal paths" into tizen accepted/tizen/unified/20210823.124235 submit/tizen/20210820.124425
Piotr Kosko [Fri, 20 Aug 2021 12:31:49 +0000 (12:31 +0000)]
Merge "[Common] Added caching custom virutal paths" into tizen

2 years agoMerge "[ACR][secure element] extension of listener" into tizen
Piotr Kosko [Fri, 20 Aug 2021 12:31:41 +0000 (12:31 +0000)]
Merge "[ACR][secure element] extension of listener" into tizen

2 years ago[Common] Added caching custom virutal paths 54/262854/1
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Fri, 20 Aug 2021 11:50:33 +0000 (13:50 +0200)]
[Common] Added caching custom virutal paths

This change is related to:
https://review.tizen.org/gerrit/#/c/platform/core/api/webapi-plugins/+/260943/

As in some scenarios (when new storage is mounted) webapi clears cache,
there is a need to restore custom virtual paths which are set with
setVirtualPath() method.

[Verification] Code compiles without errors.

Change-Id: I9dde4025526936e8988ff610f70894d4dbb00e60

2 years ago[ACR][secure element] extension of listener 97/261797/4
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Mon, 26 Jul 2021 11:00:50 +0000 (13:00 +0200)]
[ACR][secure element] extension of listener

[ACR] https://code.sec.samsung.net/jira/browse/TWDAPI-281

[Verification] Code compiles without errors.

Change-Id: I853f62f2250cf486c2a215970a2ba94299f04bb4

2 years ago[ML] Update NNFWType name of TRIx NPU Series 50/262350/2 accepted/tizen/unified/20210810.135347 submit/tizen/20210809.021120
MyungJoo Ham [Mon, 9 Aug 2021 03:06:36 +0000 (12:06 +0900)]
[ML] Update NNFWType name of TRIx NPU Series

SRNPU is an unofficial name of TRIx NPU series.
Update the name with the official name.
Fortuately "SRNPU" was first introduced with Tizen 6.5 releases.

We have decided to expose the official name of these NPU series of
TRIV and TRIA series, which are exposed via a common NPU-Engine
low-level driver: "TRIx-Engine".

Note that in some commercial products with TRIx NPU series,
the low-level drivers might be not available to applications.
In such cases, high-level drivers (with less hardware control)
that wrap the low-level drivers will be provided (e.g., VD-AIFW).

[ACR] https://code.sec.samsung.net/jira/browse/TWDAPI-280

Change-Id: I7385749ec94981c3a89fe918d548d2fc582594bd
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2 years ago[common] Add the definition of a legacy messaging interface 32/262332/1 accepted/tizen/unified/20210809.001403 submit/tizen/20210806.151755
Pawel Wasowski [Fri, 6 Aug 2021 15:00:22 +0000 (17:00 +0200)]
[common] Add the definition of a legacy messaging interface

This recent change that introduced new binary messaging interfaces,
replacing XW_MESSAGING_INTERFACE_1 with XW_MESSAGING_INTERFACE_2.
This chang broken the build of webapi-plugins-teec project, which depends
on the declaration of the legacy interface.
This commit fixes this problem, by adding the legacy interface back
to XW_Extension.h.

[Verification] webapi-plugins builds. webapi-plugins-teec builds,
when webapi-plugins built with this change is installed in GBS root.

Change-Id: Ia057a8e9ea9d51e06616a0ad16dc28b3ea342d8c

2 years ago[version] 2.85 68/262268/1 submit/tizen/20210806.090850
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Thu, 5 Aug 2021 12:52:59 +0000 (14:52 +0200)]
[version] 2.85

Change-Id: I2524f9fcf99cf55054f69bf6da38b3404ba2e98e

2 years ago[ml][single] Implemented communication in ML API 79/262079/6
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Mon, 2 Aug 2021 08:15:03 +0000 (10:15 +0200)]
[ml][single] Implemented communication in ML API

[Verification] Performance increased in Chromium console.
TCT passrate - 100%
Change-Id: I7079ec1a690696dc4acc5d827920603e3a12e9ab

2 years ago[extension] Binary messanger implementation added 02/261202/4
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Fri, 9 Jul 2021 11:47:13 +0000 (13:47 +0200)]
[extension] Binary messanger implementation added

[verification] Code compiles without errors.

Change-Id: If98eaf371ffbb47a2bf39978f9529307a9e9b06f

2 years ago[ML][Single] Fix invokeAsync 28/262228/1
Pawel Wasowski [Wed, 4 Aug 2021 14:49:28 +0000 (16:49 +0200)]
[ML][Single] Fix invokeAsync

invokeAsync implementation did not should copy the input TensorsData
object, as it was supposed to. This commit adds copying

[Verification] Tested with the snippet below several times - the outputs
of invoke and invokeAsync were always identical:

var tensorsData;
var model;

function errorCallback(error)
{
    console.log("Error during invokeAsync: " + error.message);
}

function isSameArray(a, b) {
    if(a.length != b.length) {
        return false;
    }
    for(var i=0 ; i<a.length ; i++) {
        if(a[i] != b[i]) {
            return false;
        }
    }
    return true;
}

function successCallback(tensorsDataOut)
{
    var asyncResult = tensorsDataOut.getTensorRawData(0).data;
    var syncResultTD = model.invoke(tensorsData);
    var syncResult = syncResultTD.getTensorRawData(0).data;

    if (isSameArray(syncResult, asyncResult)) {
        console.log('Sync and async versions of invoke returned the same output');
    } else {
        console.error('Outputs of sync and async invoke versions differ!');
    }
}

function run_test () {
    model = tizen.ml.single.openModel("wgt-package/models/mobilenet_v1_1.0_224_quant.tflite", null, null, "TENSORFLOW_LITE", "ANY");

    var tensorsInfo = new tizen.ml.TensorsInfo();
    tensorsInfo.addTensorInfo("tensor", "UINT8", [224, 224, 3]);
    tensorsData = tensorsInfo.getTensorsData();
    var randomData = Array.from({length: 224 * 224 * 3}, () => Math.floor(Math.random() * 255));
    var rgb = new Uint8Array(randomData);
    tensorsData.setTensorRawData(0, rgb);
    model.invokeAsync(tensorsData, successCallback, errorCallback);
};

Change-Id: Iff0d39ca6be9e1c5d2ff3c9f9fc3d061d49377c5

2 years ago[Alarm] Don't raise an error when an alarm without TYPE is found 06/261406/1 accepted/tizen/unified/20210719.025303 submit/tizen/20210716.123403
Pawel Wasowski [Thu, 15 Jul 2021 13:03:15 +0000 (15:03 +0200)]
[Alarm] Don't raise an error when an alarm without TYPE is found

tizen.alarm.get() and tizen.alarm.getAll() used to fail when alarms
without "TYPE" property in related app_control existed.
This commit returns such alarms as JS Alarm objects.

[Verification] tct-alarm-tizen-tests (auto): 100 %

I've tested in Chrome DevTools debugger, that when an alarm without
"type" property comes to JS, a valid "Alarm" object is created
(I don't provide any test code snippet, because it required stopping
app in the debugger).

Change-Id: I4b5bcea75509f454bd17b787c080417849720f5a
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
2 years ago[version] 2.84 12/261012/1 accepted/tizen/unified/20210709.081216 submit/tizen/20210708.092104
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Thu, 8 Jul 2021 09:17:29 +0000 (11:17 +0200)]
[version] 2.84

Change-Id: Iaeb9f2c1ce570ad109ea4a5c34a512b4a328442e

2 years ago[Filesystem] Change setVirtualPath method to be not enumerable 51/260951/1
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Wed, 7 Jul 2021 10:21:18 +0000 (12:21 +0200)]
[Filesystem] Change setVirtualPath method to be not enumerable

Feature of setVirtualPath is needed for proper handling virtual paths
in thread service model - related change:
https://review.tizen.org/gerrit/gitweb?p=platform/core/api/webapi-plugins.git;a=commit;h=4870490975f9cbfa3eb16cc892f3593cb74b6668

[Verification] Code compiles without errors. Code was properly
formatted.
Checked in chrome console - setVirtualPath is not iterable, but still
accessible.

Change-Id: Ia3d2720cd1267d0a4d002538f319cfd993e83d4a

2 years agoSupport setVirtualPath for thread-model wrt-service 43/260943/3
DongHyun Song [Wed, 7 Jul 2021 08:47:14 +0000 (17:47 +0900)]
Support setVirtualPath for thread-model wrt-service

thread-model wrt-service runs all service application on worker
thread as daemon process.

For the virtual path resolving, it cannot get service application's
path. i.e. /home/owner/apps_rw/{service_app_pkgid}/data, becuase
wrt-service is org.tizen.chromium-efl package.

Thus, setting virtual path will be set by wrt-service framework
before each node worker thread started.
 - node worker has own V8 context

Change-Id: I8dd5e524584ebe71416c86c1e8648a2c4cfc4b94
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
2 years agoSupport setVirtualPath for thread-model wrt-service
DongHyun Song [Wed, 7 Jul 2021 08:47:14 +0000 (17:47 +0900)]
Support setVirtualPath for thread-model wrt-service

thread-model wrt-service runs all service application on worker
thread as daemon process.

For the virtual path resolving, it cannot get service application's
path. i.e. /home/owner/apps_rw/{service_app_pkgid}/data, becuase
wrt-service is org.tizen.chromium-efl package.

Thus, setting virtual path will be set by wrt-service framework
before each node worker thread started.
 - node worker has own V8 context

Change-Id: I8dd5e524584ebe71416c86c1e8648a2c4cfc4b94
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
2 years ago[Filesystem] Fixed Blob to Uint8Array conversion 43/260843/1
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Mon, 5 Jul 2021 11:10:54 +0000 (13:10 +0200)]
[Filesystem] Fixed Blob to Uint8Array conversion

Fix inspired by this answer: https://stackoverflow.com/a/63920556/11502478

[Verification] in Chrome console:
// assume having wav file on the device
input = tizen.filesystem.openFile("documents/sample1.wav", "r")
blob = input.readBlob()  /// Blob {size: 1073218, type: ""}

output = tizen.filesystem.openFile("documents/sample1_output.wav", "w")
output.writeBlob(blob)
output.close()

output_test = tizen.filesystem.openFile("documents/sample1_output.wav", "r")
blob_test = output_test.readBlob()  /// Blob {size: 1073218, type: ""}

console.log("Verification passed: " + (blob.size === blob_test.size))

input.close()
output_test.close()

TCT (filesystem, deprecated) passrate 100%

Change-Id: I5e4beea31d69430e9dbe44a7899cf675e779c7f8

2 years ago[version] 2.83 25/260525/1 accepted/tizen/unified/20210629.130231 submit/tizen/20210628.105256
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Mon, 28 Jun 2021 08:45:05 +0000 (10:45 +0200)]
[version] 2.83

Change-Id: Ie9ee7bcf4b480406921ec878717b5592dd0cc9a5

2 years agoMerge "[ML][Single] Added InvokeAsync() implementation" into tizen
Piotr Kosko [Mon, 28 Jun 2021 05:55:56 +0000 (05:55 +0000)]
Merge "[ML][Single] Added InvokeAsync() implementation" into tizen

2 years agoMerge "[Application] Enable system events listener" into tizen
Piotr Kosko [Mon, 28 Jun 2021 05:55:48 +0000 (05:55 +0000)]
Merge "[Application] Enable system events listener" into tizen

2 years ago[ML][Single] Added InvokeAsync() implementation 20/260420/6
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Wed, 23 Jun 2021 11:32:22 +0000 (13:32 +0200)]
[ML][Single] Added InvokeAsync() implementation

[ACR] https://code.sec.samsung.net/jira/browse/TWDAPI-278

[Verification] Code compiles without errors.
TCT passrate of existing APIs didn't change.

Checked in chrome console with below snippets:
// initialize test data
model = tizen.ml.single.openModel("documents/model.tflite");

var tensorsInfo = new tizen.ml.TensorsInfo();
tensorsInfo.addTensorInfo("tensor", "UINT8", [3, 224, 224]);
var tensorsData = tensorsInfo.getTensorsData();

var tensorsInfoInvalid = new tizen.ml.TensorsInfo();
tensorsInfoInvalid.addTensorInfo("tensor", "UINT8", [3, 125, 125]);
var tensorsDataInvalid = tensorsInfoInvalid.getTensorsData();

function errorCallback(error) {
  console.log(error);
}

function successCallback(tensorsDataOut) {
  console.log("Inference finished successfully");
  console.log(tensorsDataOut.getTensorRawData(0));
  tensorsDataOut.dispose();
}

// success
// test1
model.invokeAsync(tensorsData, successCallback, errorCallback);
// test2
model.invokeAsync(tensorsData, successCallback);

// errors
// test3
model.invokeAsync(tensorsData);  // TypeMismatchError - sync
// test4
model.invokeAsync(null, successCallback);  // TypeMismatchError - sync
//  test5
model.invokeAsync(tensorsDataInvalid, successCallback, errorCallback);  // AbortError - async
// test6
model.setTimeout(1)
model.invokeAsync(tensorsData, successCallback, errorCallback);  // TimeoutError - async

// clear tensorsData
tensorsData.dispose();
tensorsInfo.dispose();

// test7 - use of disposed tesnsorsData
model.invokeAsync(tensorsData, successCallback, errorCallback);  // AbortError - sync

// clear other data
tensorsDataInvalid.dispose();
tensorsInfoInvalid.dispose();
model.close();

Change-Id: I59900d7bab9a76939e27d68cb2bcd5434f446b3d

2 years ago[version] 2.82 12/259912/1 accepted/tizen/unified/20210624.131908 submit/tizen/20210616.104612
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Wed, 16 Jun 2021 10:43:32 +0000 (12:43 +0200)]
[version] 2.82

Change-Id: I851cb3ea68068d0ea2fa38ac5eac19ca0a5904c1

2 years ago[ML] Add new HWType and NNFWType enums 91/259791/2
Rafal Walczyna [Mon, 14 Jun 2021 09:17:33 +0000 (11:17 +0200)]
[ML] Add new HWType and NNFWType enums

[XWALK-2312]
[TWDAPI-277]

Tested also with code:
var HWType = ["ANY", "NPU_SLSI"];

var NNFWType = ["ANY", "NNTR_INF", "PYTORCH", "SRNPU", "VD_AIFW"];

HWType.forEach(hw => {
    NNFWType.forEach(nnfw => {
        console.log(nnfw + ", " + hw + ": " + tizen.ml.checkNNFWAvailability(nnfw, hw))
    });
});

[Verification] 100% passrate

Change-Id: I9257240d1596c2b017581997b488a01447385060
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
2 years ago[version] 2.81 40/259540/1 accepted/tizen/unified/20210610.141235 submit/tizen/20210609.101925
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Wed, 9 Jun 2021 09:48:07 +0000 (11:48 +0200)]
[version] 2.81

Change-Id: I5225e6004d027167b720b9f1fcd1d213a9840769

2 years ago[Filesystem] Use non-static worker instead of singleton TaskQueue 82/259382/3
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Tue, 8 Jun 2021 05:41:41 +0000 (07:41 +0200)]
[Filesystem] Use non-static worker instead of singleton TaskQueue

In filesystem webapi, TaskQueue is a singleton instance used by
multiple FilesystemInstance. With thread model web service
applications, there might be smack violation because each service
app (thread) try to use same worker.

This commit resolves problem by changing usage of singleton TaskQueue to
a member worker owned by FilesystemInstance.

Commit keeps two separated workers for better operation
performance:
- global_worker queues 'global' operations on fielsystem instance e.g.
opening files, rename, move etc.
- file_worker queues only file operation as reading
Above design prevents to block 'quick' global operations in case of
long-lasting file reading/writing operation in background.

[Verification] Code compiles without errors.
Filesystem TCT passrate 100%.

Change-Id: Idf0bd1915f67b64a65fcc1afc2e17d011bb5b918
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
Signed-off-by: Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
2 years ago[Tools] Force clang-format version to 3.9 06/258706/2
Rafal Walczyna [Mon, 24 May 2021 13:02:02 +0000 (15:02 +0200)]
[Tools] Force clang-format version to 3.9

Using version newer than 3.9 results in a lot of format changes.

As user may want to use newer clang-format version for different
projects, script has been changed to use clang-format-3.9 executable.

[Verification] No change in C++ formatting

Change-Id: I4f569644549db8104bb39efc6bc1eca23ac6bbd6
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
2 years agoMerge "[Bluetooth] Fix Coverity issue" into tizen
Piotr Kosko [Thu, 20 May 2021 06:18:23 +0000 (06:18 +0000)]
Merge "[Bluetooth] Fix Coverity issue" into tizen

2 years agoMerge "[nfc] Fixing memory management for messages and records" into tizen
Piotr Kosko [Thu, 20 May 2021 06:17:59 +0000 (06:17 +0000)]
Merge "[nfc] Fixing memory management for messages and records" into tizen

2 years agoMerge "[ML][common] Fix a Coverity issue" into tizen
Piotr Kosko [Thu, 20 May 2021 04:28:08 +0000 (04:28 +0000)]
Merge "[ML][common] Fix a Coverity issue" into tizen

2 years agoMerge "[mediacontroller] Fixing Coverity issues" into tizen
Piotr Kosko [Thu, 20 May 2021 04:26:20 +0000 (04:26 +0000)]
Merge "[mediacontroller] Fixing Coverity issues" into tizen

2 years ago[Bluetooth] Fix Coverity issue 10/258510/3
Pawel Wasowski [Wed, 19 May 2021 09:56:25 +0000 (11:56 +0200)]
[Bluetooth] Fix Coverity issue

Coverity issue numbers:
1227417
1227505
1229055

[Verification] Code compiles

Change-Id: Ie05e4184cf200b69615b2e4ba92d3d5cb291d4d0
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
2 years ago[nfc] Fixing memory management for messages and records 01/258501/3
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Wed, 19 May 2021 06:23:11 +0000 (08:23 +0200)]
[nfc] Fixing memory management for messages and records

Should fix Coverity issues:
* 1227523
* 1227594
* 1228259
* 1228588
* 1229210
* 1229523
* 1229587

[Verification] Code compiles without errors.

Change-Id: I07813a855ce2d335fe783956a7af6f340a314602

2 years ago[mediacontroller] Fixing Coverity issues 00/258500/1
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Tue, 18 May 2021 11:02:27 +0000 (13:02 +0200)]
[mediacontroller] Fixing Coverity issues

Fixes: 1192721

Change-Id: I1bd564b935d35f0586e174869f7df10cd0cc705b

2 years ago[ML][common] Fix a Coverity issue 92/258492/1
Pawel Wasowski [Tue, 18 May 2021 14:11:12 +0000 (16:11 +0200)]
[ML][common] Fix a Coverity issue

Coverity issue numver: 1229783

This commit fixes a potential memory leak.

[Verification] The code compiles (it's hard to provoke the code to enter
the problematic branch, so the new code wasn't executed)

Change-Id: Id560ffdffc18ff6bbf2bc987e8e0ad6853b2cdb6

3 years ago[ML] Remove unneccessary comments and already resolved TODOs 18/256118/2
Pawel Wasowski [Mon, 29 Mar 2021 14:24:08 +0000 (16:24 +0200)]
[ML] Remove unneccessary comments and already resolved TODOs

[Verification] Code compiles

Change-Id: I4ccd17dcee4cc1344c739d20492c93f94f08545e
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
3 years ago[ML][Pipeline] Prevent a crash in ~CustomFilter and unregister failures 58/255958/6 accepted/tizen/unified/20210331.063719 submit/tizen/20210326.074032 submit/tizen/20210331.053133
Pawel Wasowski [Thu, 25 Mar 2021 10:42:12 +0000 (11:42 +0100)]
[ML][Pipeline] Prevent a crash in ~CustomFilter and unregister failures

This commit fixes a crash that used to follow the sequence below:
1. ~CustomFilter() is called, but native
ml_pipeline_custom_easy_filter_unregister()
fails to unregister the filter. CustomFilter is
removed, but a pointer to this object (now defunct)
is still kept in CustomFilter::valid_filters_ container.
2. LockRequestIdToJSResponseMutexIfFilterIsNotWaitingForJSResponses,
that iterates over valid_filters_ accesses the destroyed object
and thus crashes the app.

This commit also changes the order of destruction of Pipeline and
CustomFilter objects managed by Web API. Pipeline objects should
be destroyed first.

[Verification] Tested in Chrome DevTools with the snippets below, works
fine.

inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo("3D", "UINT8", [4, 20, 15, 1]);
outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo("flat", "UINT8", [1200]);

filterCB = function (input, output) {
  console.log('hello');
  tizen.ml.pipeline.unregisterCustomFilter("flattenFilter");
  console.log('bye');
}

retValue = tizen.ml.pipeline.registerCustomFilter("flattenFilter", filterCB,
                                                  inputTI, outputTI,
                                                  console.warn);

pipelineDefinition = "videotestsrc num-buffers=3 " +
                    "! video/x-raw,width=20,height=15,format=BGRA " +
                    "! tensor_converter " +
                    "! tensor_filter framework=custom-easy model=flattenFilter "
                    + "! fakesink";
pipeline = tizen.ml.pipeline.createPipeline(pipelineDefinition);
pipeline.start();

// hello
// WebAPIException {name: "AbortError", message:
// "CustomFilter has thrown exception: InvalidStateErr CustomFilter has
// thrown exception: InvalidStateError: The custom filter is processing
// data now. Stop the pipeline to unregister the filter."}

// <no deadlock>

///////////////////////////////////////////////////////////////////////////
inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo("3D", "UINT8", [4, 20, 15, 1]);
outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo("ti1", "UINT8", [1200]);

customFilter = function (input, output) {
  try {
      inputTI.dispose();
      outputTI.dispose();
      pipeline.stop();
      pipeline.dispose();
  } catch (err) {
      console.warn(err);
  }
}

tizen.ml.pipeline.registerCustomFilter("flattenFilter", customFilter, inputTI, outputTI);

pipelineDefinition = "videotestsrc num-buffers=3 " +
                    "! video/x-raw,width=20,height=15,format=BGRA " +
                    "! tensor_converter " +
                    "! tensor_filter framework=custom-easy model=flattenFilter " +
                    "! fakesink";
pipeline = tizen.ml.pipeline.createPipeline(pipelineDefinition);
pipeline.start();

// WebAPIException {name: "InvalidStateError",
// message: "Pipeline cannot be disposed when at least one custom filter
// is currently processing data.",

// <no deadlock>

///////////////////////////////////////////////////////////////////////////
// Valid CustomFilter callback - the happy scenario
var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenAndSet123 = function(input, output) {
    console.log("Custom filter called");

    var rawOutputData = new Uint8Array(1200);
    for (var i = 0; i < rawOutputData.length; ++i) {
        rawOutputData[i] = 123;
    }

    output.setTensorRawData(0, rawOutputData);
    return 0;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenAndSet123, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING
// <CustomFilter and SinkListener callbacks' outputs 3 times>

////////////////////////////////////////////////////////////

// Valid CustomFilter callback - the happy scenario; ignore the data

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input, output) {
    console.log("Custom filter called");
        return 1; // ignore data
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// Custom filter called
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING

////////////////////////////////////////////////////////////

// Valid CustomFilter callback - CustomFilter returns an error

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input, output) {
    console.log("Custom filter called");
        return -1;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING

////////////////////////////////////////////////////////////

// Invalid CustomFilterOutput.status
var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input) {
    console.log("Custom filter called");

    return 123;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// InvalidValuesError,
//  message: "CustomFilterOutput.status === 1 is the only legal positive value"

////////////////////////////////////////////////////////////
// Check if {input, output}.dispose() and input.setTensorRawData()
// have any effect

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenAndSet123 = function(input, output) {
    console.log("Custom filter called");

    // dispose should have no efect
    input.dispose();
    console.log('input count: ' + input.tensorsInfo.count);
    // dispose should have no efect
    input.dispose();
    console.log('output count: ' + output.tensorsInfo.count);

    var rawOutputData = new Uint8Array(1200);
    for (var i = 0; i < rawOutputData.length; ++i) {
        rawOutputData[i] = 123;
    }

    output.setTensorRawData(0, rawOutputData);

    // this call should have no effect
    input.setTensorRawData(0, rawOutputData);

    return 0;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenAndSet123, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

Change-Id: I4c5b773203239321de5826b5e4908c50cd84b7d6
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
3 years agoMerge "[Common][ML] Fixing SVACE issues and code formatting" into tizen
Piotr Kosko [Wed, 24 Mar 2021 09:50:41 +0000 (09:50 +0000)]
Merge "[Common][ML] Fixing SVACE issues and code formatting" into tizen

3 years ago[Archive] Fixed Coverity issue 52/255852/2
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Wed, 24 Mar 2021 08:09:17 +0000 (09:09 +0100)]
[Archive] Fixed Coverity issue

Issue id: 1218132

[Verification]
  Code compiles, TCT passrate 100%.
  Coverity showed no issues:
   https://analysishub.sec.samsung.net/service/analyses/418348

Change-Id: I5d28891a7b2c3b42237c661474ea88d00e028184

3 years ago[ML][single] Change InvalidValues to TypeMismatch 85/255785/1 submit/tizen/20210324.052810
Rafal Walczyna [Tue, 23 Mar 2021 14:32:25 +0000 (15:32 +0100)]
[ML][single] Change InvalidValues to TypeMismatch

In case when no arguments are provided, TypeMismatch should be thrown.

Verification: Tested in google chrome console.

Change-Id: Iab1f606c8a731c096dd93f5e38b0ec4c9b6beb6f
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
3 years ago[Common][ML] Fixing SVACE issues and code formatting 14/255614/1
Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics [Fri, 19 Mar 2021 11:20:55 +0000 (12:20 +0100)]
[Common][ML] Fixing SVACE issues and code formatting

[SVACE] 1222586, 1222593

[Verification] Code compiles without errors.

Change-Id: Ibf34be9edb25f1b4e61e8480c9b6ad42262d42a4

3 years agoMerge "[ML][single] Fix SingleShot.input attribute change" into tizen accepted/tizen/unified/20210319.140807 submit/tizen/20210319.060422
Piotr Kosko [Fri, 19 Mar 2021 06:03:37 +0000 (06:03 +0000)]
Merge "[ML][single] Fix SingleShot.input attribute change" into tizen

3 years ago[ML][single] Fix SingleShot.input attribute change 58/255458/1
Rafal Walczyna [Thu, 18 Mar 2021 14:08:32 +0000 (15:08 +0100)]
[ML][single] Fix SingleShot.input attribute change

Changing input attribute should enable invoking model with different tensor.
User should not be able to modify or dispose input by direct call.
Change is only possible by replacing whole object.

Code:

var ti1 = new tizen.ml.TensorsInfo()
ti1.addTensorInfo("three", "FLOAT32", [1, 1, 1, 1])
var td1 = ti1.getTensorsData(0);
var ti3 = new tizen.ml.TensorsInfo()
ti3.addTensorInfo("three", "FLOAT32", [3, 1, 1, 1])
var td3 = ti3.getTensorsData(0);

var model = tizen.ml.single.openModel("documents/add.tflite", null, null, "ANY", "ANY", false)
model.invoke(td1)
model.input = ti3
model.invoke(td3)

[Verification] Tested in Google Chrome console

Change-Id: Iac17fd72d7e417d30bad983f6c349bd5e5ef05ed
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
3 years agoMerge "[ML][Pipeline] Prevent deadlock in CustomFilter" into tizen
Piotr Kosko [Thu, 18 Mar 2021 12:56:33 +0000 (12:56 +0000)]
Merge "[ML][Pipeline] Prevent deadlock in CustomFilter" into tizen

3 years ago[ML][Pipeline] Prevent deadlock in CustomFilter 44/255244/8
Pawel Wasowski [Mon, 15 Mar 2021 15:52:07 +0000 (16:52 +0100)]
[ML][Pipeline] Prevent deadlock in CustomFilter

ACR: TWDAPI-274

A deadlock could happen in 2 scenarios:
1. An attempt of unregistering a CustomFilter from its callback, (i.e.
calling tizen.ml.pipeline.unregisterCustomFilter('xxx') from xxx's
CustomFilter callback).
2. An attempt of disposing the pipeline using a CustomFilter which is
currently processing data.
This commit fixes the problems.

[Verification] Tested in Chrome DevTools with the snippets below, works
fine.

inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo("3D", "UINT8", [4, 20, 15, 1]);
outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo("flat", "UINT8", [1200]);

filterCB = function (input, output) {
  console.log('hello');
  tizen.ml.pipeline.unregisterCustomFilter("flattenFilter");
  console.log('bye');
}

retValue = tizen.ml.pipeline.registerCustomFilter("flattenFilter", filterCB,
                                                  inputTI, outputTI,
                                                  console.warn);

pipelineDefinition = "videotestsrc num-buffers=3 " +
                    "! video/x-raw,width=20,height=15,format=BGRA " +
                    "! tensor_converter " +
                    "! tensor_filter framework=custom-easy model=flattenFilter "
                    + "! fakesink";
pipeline = tizen.ml.pipeline.createPipeline(pipelineDefinition);
pipeline.start();

// hello
// WebAPIException {name: "AbortError", message:
// "CustomFilter has thrown exception: InvalidStateErr CustomFilter has
// thrown exception: InvalidStateError: The custom filter is processing
// data now. Stop the pipeline to unregister the filter."}

// <no deadlock>

///////////////////////////////////////////////////////////////////////////
inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo("3D", "UINT8", [4, 20, 15, 1]);
outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo("ti1", "UINT8", [1200]);

customFilter = function (input, output) {
  try {
      inputTI.dispose();
      outputTI.dispose();
      pipeline.stop();
      pipeline.dispose();
  } catch (err) {
      console.warn(err);
  }
}

tizen.ml.pipeline.registerCustomFilter("flattenFilter", customFilter, inputTI, outputTI);

pipelineDefinition = "videotestsrc num-buffers=3 " +
                    "! video/x-raw,width=20,height=15,format=BGRA " +
                    "! tensor_converter " +
                    "! tensor_filter framework=custom-easy model=flattenFilter " +
                    "! fakesink";
pipeline = tizen.ml.pipeline.createPipeline(pipelineDefinition);
pipeline.start();

// WebAPIException {name: "InvalidStateError",
// message: "Pipeline cannot be disposed when at least one custom filter
// is currently processing data.",

// <no deadlock>

///////////////////////////////////////////////////////////////////////////
// Valid CustomFilter callback - the happy scenario
var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenAndSet123 = function(input, output) {
    console.log("Custom filter called");

    var rawOutputData = new Uint8Array(1200);
    for (var i = 0; i < rawOutputData.length; ++i) {
        rawOutputData[i] = 123;
    }

    output.setTensorRawData(0, rawOutputData);
    return 0;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenAndSet123, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING
// <CustomFilter and SinkListener callbacks' outputs 3 times>

////////////////////////////////////////////////////////////

// Valid CustomFilter callback - the happy scenario; ignore the data

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input, output) {
    console.log("Custom filter called");
        return 1; // ignore data
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// Custom filter called
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING

////////////////////////////////////////////////////////////

// Valid CustomFilter callback - CustomFilter returns an error

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input, output) {
    console.log("Custom filter called");
        return -1;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING

////////////////////////////////////////////////////////////

// Invalid CustomFilterOutput.status
var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input) {
    console.log("Custom filter called");

    return 123;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// InvalidValuesError,
//  message: "CustomFilterOutput.status === 1 is the only legal positive value"

////////////////////////////////////////////////////////////
// Check if {input, output}.dispose() and input.setTensorRawData()
// have any effect

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenAndSet123 = function(input, output) {
    console.log("Custom filter called");

    // dispose should have no efect
    input.dispose();
    console.log('input count: ' + input.tensorsInfo.count);
    // dispose should have no efect
    input.dispose();
    console.log('output count: ' + output.tensorsInfo.count);

    var rawOutputData = new Uint8Array(1200);
    for (var i = 0; i < rawOutputData.length; ++i) {
        rawOutputData[i] = 123;
    }

    output.setTensorRawData(0, rawOutputData);

    // this call should have no effect
    input.setTensorRawData(0, rawOutputData);

    return 0;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenAndSet123, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

Change-Id: Id6cda7782e3065248b2f2c5f859ca2af07c108a6
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
3 years ago[ML][Pipeline] Remove InvalidValuesError from createPipeline 80/255380/1
Pawel Wasowski [Wed, 17 Mar 2021 17:26:29 +0000 (18:26 +0100)]
[ML][Pipeline] Remove InvalidValuesError from createPipeline

ACR: TWDAPI-274

This commit removes InvalidValuesError from the list of valid
tizen.ml.pipeline.createPipeline() exceptions, because we cannot
reliably detect, when a pipeline description is invalid.
Instead, AbortError with custom message, suggesting that the
description may be invalid, will be used.

[Verification] Tested in Chrome DevTools with the snippets below, works
fine

// Invalid pipeline definition
var pipeline_def = "invalid";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})
// WebAPIException {name: "AbortError", message: "Could not create pipeline:
// invalid pipeline description or an internal error"}

//////////////////////////////////////////////////////////////////////
// Valid pipeline definition

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenAndSet123 = function(input, output) {
    console.log("Custom filter called");

    // dispose should have no efect
    input.dispose();
    console.log('input count: ' + input.tensorsInfo.count);
    // dispose should have no efect
    input.dispose();
    console.log('output count: ' + output.tensorsInfo.count);

    var rawOutputData = new Uint8Array(1200);
    for (var i = 0; i < rawOutputData.length; ++i) {
        rawOutputData[i] = 123;
    }

    output.setTensorRawData(0, rawOutputData);

    // this call should have no effect
    input.setTensorRawData(0, rawOutputData);

    return 0;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenAndSet123, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// pipeline starts properly

Change-Id: If8d08160cb98b3acc34812f47b2741c2cce83cd8
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
3 years ago[version] 2.80 94/255194/1 accepted/tizen/unified/20210316.151300 submit/tizen/20210315.104011
Piotr Kosko/Native/Web API (PLT) /SRPOL/Engineer/Samsung Electronics [Mon, 15 Mar 2021 06:12:25 +0000 (07:12 +0100)]
[version] 2.80

Change-Id: I70978ba74a8a100745631723bdccd66239b7224e

3 years agoMerge "[ML][Pipeline] Fix issues reported by TCT team" into tizen
Piotr Kosko [Mon, 15 Mar 2021 06:05:05 +0000 (06:05 +0000)]
Merge "[ML][Pipeline] Fix issues reported by TCT team" into tizen

3 years ago[ML][Pipeline] Fix issues reported by TCT team 47/255147/3
Pawel Wasowski [Fri, 12 Mar 2021 14:32:18 +0000 (15:32 +0100)]
[ML][Pipeline] Fix issues reported by TCT team

Fixed problems:
- Pipeline::{getNodeInfo, getSwitch, getValve}: throw TypeMismatchError
when no argument is passed
- NodeInfo::setProperty: throw TypeMismatchError, instead of AbortError
when value type is other than expected
- Pipeline::unregisterSinkListener: throw InvalidValuesError when sink
has not been registered

[Verification] Code was tested with the snippets below and worked fine

///// checking problems with getNodeInfo, getSwitch, getValve,
///// and unregisterSinkListener
var pipelineDefinition = "videotestsrc name=vsrc is-live=true " +
                         "! videoconvert " +
                         "! videoscale name=vscale " +
                         "! video/x-raw,format=RGBx,width=224,height=224,framerate=60/1 " +
                         "! tensor_converter " +
                         "! valve name=valvex " +
                         "! input-selector name=is01 " +
                         "! tensor_sink name=sinkx";
var pipeline = tizen.ml.pipeline.createPipeline(pipelineDefinition);

pipeline.getNodeInfo();
// TypeMismatchError

pipeline.getSwitch();
// TypeMismatchError

pipeline.getValve();
// TypeMismatchError

pipeline.unregisterSinkListener('test')
// InvalidValuesError

///// checking problem with setProperty
pipelineDefinition = "videotestsrc name=vsrc is-live=true " +
                    "! videoconvert " +
                    "! videoscale name=vscale " +
                    "! video/x-raw,format=RGBx,width=224,height=224,framerate=60/1 " +
                    "! tensor_converter " +
                    "! valve name=valvex " +
                    "! input-selector name=is01 " +
                    "! tensor_sink name=sinkx";
pipeline = tizen.ml.pipeline.createPipeline(pipelineDefinition);
nodeInfo = pipeline.getNodeInfo("vsrc");
nodeInfo.setProperty("is-live", "DOUBLE", NaN);
// TypeMismatchError

Change-Id: I25438b037e0a2dd2f91f8d9b398cffcaf457386b
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
3 years ago[ML][Single] Fix issues that came out after TCT tests 59/255159/1
Rafal Walczyna [Fri, 12 Mar 2021 12:23:06 +0000 (13:23 +0100)]
[ML][Single] Fix issues that came out after TCT tests

- SingleShot.openModel should throw TypeError when no arguments provided

[Verification] Tested in chrome-dev console

Change-Id: I13b7946aa90f86ff4becccb9834b76d4f6bf6d22
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
3 years agoMerge "[ML][Pipeline] Invalidate CustomFilter arguments after return" into tizen
Piotr Kosko [Fri, 12 Mar 2021 10:17:40 +0000 (10:17 +0000)]
Merge "[ML][Pipeline] Invalidate CustomFilter arguments after return" into tizen

3 years ago[ML][Pipeline] Invalidate CustomFilter arguments after return 24/254924/4
Pawel Wasowski [Wed, 10 Mar 2021 12:38:22 +0000 (13:38 +0100)]
[ML][Pipeline] Invalidate CustomFilter arguments after return

ACR: TWDAPI-274

This commit makes input and output of a JS CustomFilter act as if they
were disposed after the callback's return.

[Verification] Change was tested in Chrome DevTools with the snippets
below. It works fine.

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenAndSet123 = function(input, output) {
    console.log("Custom filter called");

    var rawOutputData = new Uint8Array(1200);
    for (var i = 0; i < rawOutputData.length; ++i) {
        rawOutputData[i] = 123;
    }

    output.setTensorRawData(0, rawOutputData);

    console.log(input);

    return 0;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenAndSet123, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// TensorsData {_id: 0, _tensorsInfo: TensorsInfo, _disposable: false}
// PAUSED

pipeline.start()

// CustomFilter is called 3 times

inputFromCustomFilter.getTensorRawData(0)
inputFromCustomFilter.tensorsInfo
outputFromCustomFilter.getTensorRawData(0)
outputFromCustomFilter.tensorsInfo
// The 4 lines above result in the following exception
// WebAPIException {name: "AbortError", message: "TensorsData is disposed"}
// as expected

//////////////////////////////////////////////////////////////////////////

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var inputTD = inputTI.getTensorsData()

inputTD.dispose()

inputTD.tensorsInfo
inputTD.getTensorRawData(0)
// The 2 lines above result in the following exception
// WebAPIException {name: "AbortError", message: "TensorsData is disposed"}
// as expected - the behavior of TensorsData.dispose() did not change

Change-Id: Ib6c6afc4bb09ad2ce04bb85650b79868e9923b7b
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
3 years ago[ML][Common] Fix issues that came out after TCT tests 31/255131/1
Rafal Walczyna [Fri, 12 Mar 2021 07:55:42 +0000 (08:55 +0100)]
[ML][Common] Fix issues that came out after TCT tests

- tizen.ml.single and tizen.ml.prototype should be not writable
- TensorsInfo.addTensorsInfo should return newly added tensors info id
- ValidateBufferForTensorsData issue

[Verification] Tested in chromium console

Change-Id: I9ba7e074c79ffc7acb4de32a87a42db6c5f22beb
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
3 years agoMerge "[ML] Change InvalidValuesError to TypeMismatchError for no args" into tizen accepted/tizen/unified/20210312.142331 submit/tizen/20210312.072248
Piotr Kosko [Fri, 12 Mar 2021 05:32:20 +0000 (05:32 +0000)]
Merge "[ML] Change InvalidValuesError to TypeMismatchError for no args" into tizen

3 years agoMerge "[MediaController] Add guards to map of playlists' handles" into tizen
Piotr Kosko [Fri, 12 Mar 2021 05:25:37 +0000 (05:25 +0000)]
Merge "[MediaController] Add guards to map of playlists' handles" into tizen

3 years ago[ML] Change InvalidValuesError to TypeMismatchError for no args 59/255059/1
Rafal Walczyna [Thu, 11 Mar 2021 14:06:57 +0000 (15:06 +0100)]
[ML] Change InvalidValuesError to TypeMismatchError for no args

When function is called without args, converter throws TypeError.
This commit unifies it.

code_format has been also applied.

[Verification] Builts successful, tested in chrome console

Change-Id: I032fd3f78e06b561ae472cdbbafe3bcf4092a6d9
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
3 years ago[MediaController] Add guards to map of playlists' handles 05/254805/4
Rafal Walczyna [Tue, 9 Mar 2021 11:00:50 +0000 (12:00 +0100)]
[MediaController] Add guards to map of playlists' handles

Previously only mc_server handle were guarded by mutexes.
Playlist also needs one.

[Verification] Tested on TM1, tct-mediacontroller pass 100% x 10, no issue occurred.

Change-Id: I155cc4f2dd87d4b1237537532105b7c251689279
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
3 years ago[ML][Pipeline][Single] Fix SVACE issues 11/254911/4
Pawel Wasowski [Wed, 10 Mar 2021 10:31:04 +0000 (11:31 +0100)]
[ML][Pipeline][Single] Fix SVACE issues

This commit fixes the following issues reported on
analysishub.sec.samsung.net (WGIDs):
- 457566
- 457567
- 457568

[Verification] Code compiles. SVACE analysis after
applying the patch
(https://analysishub.sec.samsung.net/service/analyses/394936)
found no errors.

CustomFilter tested in Chrome DevTools with the
snippet below works fine

// Valid CustomFilter callback - the happy scenario
var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenAndSet123 = function(input, output) {
    console.log("Custom filter called");

    var rawOutputData = new Uint8Array(1200);
    for (var i = 0; i < rawOutputData.length; ++i) {
        rawOutputData[i] = 123;
    }

    output.setTensorRawData(0, rawOutputData);
    return 0;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenAndSet123, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING
// <CustomFilter and SinkListener callbacks' outputs 3 times>

Change-Id: Id1d35167532c3aeecbd3c73c3546b80e31e8f76c
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
3 years ago[Application] Enable system events listener 20/254620/4
Piotr Kosko/Native/Web API (PLT) /SRPOL/Engineer/Samsung Electronics [Fri, 5 Mar 2021 09:56:59 +0000 (10:56 +0100)]
[Application] Enable system events listener

[ACR] https://code.sec.samsung.net/jira/browse/TWDAPI-276

[Verification] Code compiles without errors.
TCT passrate for application, appcontrol, capablity, deprecated - 100%

Checked some of native events from:
https://docs.tizen.org/application/native/guides/app-management/event/

var app = tizen.application.getCurrentApplication();
watchId =
        app.addEventListener({"name": "location_enable_state"}, function(event, data)
        {
          console.log("Event" + JSON.stringify(event) + " Data: " + JSON.stringify(data));
        });

var watchId =
        app.addEventListener({"appId": app.appInfo.id, "name": "custom_user_event"}, function(event, data)
        {
          console.log("Event" + JSON.stringify(event) + " Data: " + JSON.stringify(data));
          /* Do something. */
        });

after triggering associated event - listener seem to be called properly:
> app.broadcastEvent({'name': 'custom_user_event'}, {'test': 't'})
console-via-logger.js:173 Event{"appId":"Bwk0GVY1f3.BasicUI40","name":"custom_user_event"} Data: {"test":"t"}
> // ebable location on device
console-via-logger.js:173 Event{"name":"LOCATION_ENABLE_STATE"} Data: {"value":"disabled","type":"LOCATION_ENABLE_STATE"}

Change-Id: I73ae5b2b180c441db4f2da2eb84292b04b8e188f
Id: I65c83787c7d366fef918103be882370614034354

3 years agoMerge "[SPEC][UT] Add conditions to unit test build and run" into tizen
Piotr Kosko [Mon, 8 Mar 2021 05:49:45 +0000 (05:49 +0000)]
Merge "[SPEC][UT] Add conditions to unit test build and run" into tizen

3 years ago[SPEC][UT] Add conditions to unit test build and run 77/254477/3
Rafal Walczyna [Wed, 3 Mar 2021 10:30:09 +0000 (11:30 +0100)]
[SPEC][UT] Add conditions to unit test build and run

Unit tests can be run inside GBS - by setting flag in spec file.

[Verification] Built successful with unified, profile mobile, profile wearable
               both with ut flags on and off.

Change-Id: I2a89562893182cf35cd41f8b396a19c4777fe580
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
3 years ago[systeminfo] Fix armv8l and texture_format on RPI 63/254563/1
Rafal Walczyna [Thu, 4 Mar 2021 13:37:02 +0000 (14:37 +0100)]
[systeminfo] Fix armv8l and texture_format on RPI

[TSDF-257]

- RPI4 has armv8l architecture, which was not supported by webapi.
- RPI4 does not support any opnegles texture_format

[Verification] TM1 6.5 systeminfo TCT 100% pass. Tested in chrome console on RPI4.

Change-Id: Ic479e2860250ebe15033a2cf8a53f827a2bd4bcd
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
3 years ago[version] 2.79 38/254538/1 accepted/tizen/unified/20210305.141713 submit/tizen/20210304.103045
Piotr Kosko/Native/Web API (PLT) /SRPOL/Engineer/Samsung Electronics [Thu, 4 Mar 2021 08:53:43 +0000 (09:53 +0100)]
[version] 2.79

Change-Id: I10b8b53727146f2ef80b8e98f1fcb5365ffd3ae8

3 years agoMerge "[ML][Pipeline] Change CustomFilter interface and implementation" into tizen
Piotr Kosko [Wed, 3 Mar 2021 13:12:16 +0000 (13:12 +0000)]
Merge "[ML][Pipeline] Change CustomFilter interface and implementation" into tizen

3 years agoMerge "[ML][Single] Implemented setTimeout and close" into tizen
Piotr Kosko [Wed, 3 Mar 2021 13:11:19 +0000 (13:11 +0000)]
Merge "[ML][Single] Implemented setTimeout and close" into tizen

3 years agoMerge "[GYP] Update build configuration for ML API" into tizen
Piotr Kosko [Tue, 2 Mar 2021 13:38:09 +0000 (13:38 +0000)]
Merge "[GYP] Update build configuration for ML API" into tizen

3 years ago[ML][Single] Implemented setTimeout and close 22/254322/5
Piotr Kosko/Native/Web API (PLT) /SRPOL/Engineer/Samsung Electronics [Fri, 26 Feb 2021 06:09:19 +0000 (07:09 +0100)]
[ML][Single] Implemented setTimeout and close

[ACR] https://code.sec.samsung.net/jira/browse/TWDAPI-273

[Verification] Code compiles. Verified in chrome console:

var m = tizen.ml.single.openModel("/opt/usr/home/owner/media/Documents/mobilenet_v1_1.0_224_quant.tflite")   // success
// timeout check
// check if invoke works 'normally'
var ti = new tizen.ml.TensorsInfo();
ti.addTensorInfo("tensor", "UINT8", [3, 224, 224])
var td = ti.getTensorsData();
var tdout = m.invoke(td)  // success

// check if timeout will change behaviour of invoke, while short timeout is set
m.setTimeout(5)    // success
var tdout = m.invoke(td)  // TimeoutError

// check empty arguments
m.setTimeout()     // InvalidValuesError

// close check
m.close()    // success
// Abort error: "SingleShot object was closed and using it is no longer possible."
// for following calls:
m.close()
m.input
m.output
m.invoke()
m.getValue()
m.setValue()
m.setTimeout()

Change-Id: I3ff7b899fc1527f62aea24387cadf4d0f0db3f05

3 years ago[GYP] Update build configuration for ML API 19/254419/1
Piotr Kosko/Native/Web API (PLT) /SRPOL/Engineer/Samsung Electronics [Tue, 2 Mar 2021 12:59:20 +0000 (13:59 +0100)]
[GYP] Update build configuration for ML API

Change-Id: Icb9f4993e8bbeae6e2c12bfca6689d279823d54e

3 years ago[ML][Pipeline] Change CustomFilter interface and implementation 23/254323/9
Pawel Wasowski [Thu, 25 Feb 2021 19:02:20 +0000 (20:02 +0100)]
[ML][Pipeline] Change CustomFilter interface and implementation

ACR: TWDAPI-274

CustomFilter API and implementation are changed to avoid
copying TensorsData.

Change-Id: Id48b774c86b65f5b45f3dd74733c006b6a729b8c
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
[Verification] Code tested with the snippets below works fine

// Valid CustomFilter callback - the happy scenario
var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenAndSet123 = function(input, output) {
    console.log("Custom filter called");

    var rawOutputData = new Uint8Array(1200);
    for (var i = 0; i < rawOutputData.length; ++i) {
        rawOutputData[i] = 123;
    }

    output.setTensorRawData(0, rawOutputData);
    return 0;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenAndSet123, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING
// <CustomFilter and SinkListener callbacks' outputs 3 times>

////////////////////////////////////////////////////////////

// Valid CustomFilter callback - the happy scenario; ignore the data

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input, output) {
    console.log("Custom filter called");
        return 1; // ignore data
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// Custom filter called
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING

////////////////////////////////////////////////////////////

// Valid CustomFilter callback - CustomFilter returns an error

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input, output) {
    console.log("Custom filter called");
        return -1;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING

////////////////////////////////////////////////////////////

// Invalid CustomFilterOutput.status
var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input) {
    console.log("Custom filter called");

    return 123;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// InvalidValuesError,
//  message: "CustomFilterOutput.status === 1 is the only legal positive value"

////////////////////////////////////////////////////////////
// Check if {input, output}.dispose() and input.setTensorRawData()
// have any effect

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenAndSet123 = function(input, output) {
    console.log("Custom filter called");

    // dispose should have no efect
    input.dispose();
    console.log('input count: ' + input.tensorsInfo.count);
    // dispose should have no efect
    input.dispose();
    console.log('output count: ' + output.tensorsInfo.count);

    var rawOutputData = new Uint8Array(1200);
    for (var i = 0; i < rawOutputData.length; ++i) {
        rawOutputData[i] = 123;
    }

    output.setTensorRawData(0, rawOutputData);

    // this call should have no effect
    input.setTensorRawData(0, rawOutputData);

    return 0;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenAndSet123, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

Change-Id: Id48b774c86b65f5b45f3dd74733c006b6a729b8c
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
3 years ago[ML][single] SingleShot.invoke implementation added 87/254287/4
Rafal Walczyna [Thu, 25 Feb 2021 12:38:46 +0000 (13:38 +0100)]
[ML][single] SingleShot.invoke implementation added

ACR: TWDAPI-273

Test code:
var ti1 = new tizen.ml.TensorsInfo()
ti1.addTensorInfo("three", "FLOAT32", [1, 1, 1, 1])
var td1 = ti1.getTensorsData(0);
td1.setTensorRawData(0, [1]);
var ti3 = new tizen.ml.TensorsInfo()
ti3.addTensorInfo("three", "FLOAT32", [3, 1, 1, 1])
var td3 = ti3.getTensorsData(0);
td3.setTensorRawData(0, [1, 2, 3]);
var ti5 = new tizen.ml.TensorsInfo()
ti5.addTensorInfo("three", "FLOAT32", [5, 1, 1, 1])
var td5 = ti5.getTensorsData(0);
td5.setTensorRawData(0, [1, 2, 3, 4, 5]);

// using model from nnstreamer API
var m = tizen.ml.single.openModel('documents/add.tflite', null, null, "ANY", "ANY")

m.invoke(td1) // ok
m.invoke(td3) // error
m.invoke(td5) // error

var m_dynamic = tizen.ml.single.openModel('documents/add.tflite', null, null, "ANY", "ANY", true)

m_dynamic.invoke(td1) // ok
m_dynamic.invoke(td3) // ok
m_dynamic.invoke(td5) // ok

[Verification] Built successful. Tested in Chrome Dev console.

Change-Id: I25218c122c57d6cb781181388f94a27ee0605ee8
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
3 years agoMerge "[ML][Pipeline] Implement CustomFilter callback" into tizen
Piotr Kosko [Thu, 25 Feb 2021 12:09:10 +0000 (12:09 +0000)]
Merge "[ML][Pipeline] Implement CustomFilter callback" into tizen

3 years agoMerge "[ML][Pipeline] Implement {register, unregister}CustomFilter" into tizen
Piotr Kosko [Thu, 25 Feb 2021 12:08:46 +0000 (12:08 +0000)]
Merge "[ML][Pipeline] Implement {register, unregister}CustomFilter" into tizen

3 years ago[ML][Pipeline] Implement CustomFilter callback 68/253768/15
Pawel Wasowski [Mon, 22 Feb 2021 10:07:11 +0000 (11:07 +0100)]
[ML][Pipeline] Implement CustomFilter callback

ACR: TWDAPI-274

This is the second part of CustomFilter implementation. It adds
transfering the data between JS and C++.

[Verification] Code tested with the snippets below works fine

// Valid CustomFilter callback - the happy scenario
var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input) {
    console.log("Custom filter called");
    var outputTD = outputTI.getTensorsData();
    var rawInputData = input.getTensorRawData(0);
    for (var i = 0; i < rawInputData.data.size; ++i) {
        rawInputData.data[i] = rawInputData.data[i] + 1;
    }
        outputTD.setTensorRawData(0, rawInputData.data);
        return new tizen.ml.CustomFilterOutput(0, outputTD);
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING
// <CustomFilter and SinkListener callbacks' outputs 3 times>

////////////////////////////////////////////////////////////

// Valid CustomFilter callback - the happy scenario; ignore the data

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input) {
    console.log("Custom filter called");
        return new tizen.ml.CustomFilterOutput(1, null); // ignore data
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// Custom filter called
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING

////////////////////////////////////////////////////////////

// Valid CustomFilter callback - CustomFilter returns an error

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input) {
    console.log("Custom filter called");
        return new tizen.ml.CustomFilterOutput(-1, null);
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING

////////////////////////////////////////////////////////////

// Invalid CustomFilter callback output - status == 0, but no
TensorsData

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input) {
    console.log("Custom filter called");

    return new tizen.ml.CustomFilterOutput(0, null);
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// custom filter error:
// {name: "AbortError", message: "CustomFilter has thrown exception:
// {'code':0, 'name':'InvalidValuesError' ..."}

////////////////////////////////////////////////////////////

// Invalid CustomFilter callback output - non-CustomFilterOutput

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input) {
    console.log("Custom filter called");

    return 123;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// custom filter error:
// {name: "TypeMismatchError",
// message: "The value returned from CustomFilter is not a
// CustomFilterOutput object"}

////////////////////////////////////////////////////////////
// CustomFilter callback returns TensorsData with dimensions other
// than specified in tizen.ml.pipeline.registerCustomFilter(...) call

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input) {
    console.log("Custom filter called");

    var invalidOutputTI = new tizen.ml.TensorsInfo();
    invalidOutputTI.addTensorInfo('ti1', 'UINT8', [5, 2]);

    var outputTD = invalidOutputTI.getTensorsData();

    outputTD.setTensorRawData(0, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
    return new tizen.ml.CustomFilterOutput(0, outputTD);
}

// register - the happy scenario
tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called

// custom filter error: {name: "InvalidValuesError",
// message: "Output's TensorsInfo is not equal to expected"}

pipeline.start()

////////////////////////////////////////////////////////////

// CustomFilter callback returns non-TensorsData as output

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input) {
    console.log("Custom filter called");

    return new tizen.ml.CustomFilterOutput(0, "this should be TensorsData");
}

// register - the happy scenario
tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// custom filter error:
// {name: "AbortError", message: "CustomFilter has thrown exception: {
..."}

////////////////////////////////////////////////////////////

// Invalid CustomFilterOutput.status

new tizen.ml.CustomFilterOutput(666, null);
// InvalidValuesError,
//  message: "CustomFilterOutput.status === 1 is the only legal positive value"

Change-Id: Icf2edee853eb97dde54ecd83f00164b302aa29ca
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
3 years ago[ML][Pipeline] Implement {register, unregister}CustomFilter 10/253510/13
Pawel Wasowski [Thu, 18 Feb 2021 10:09:04 +0000 (11:09 +0100)]
[ML][Pipeline] Implement {register, unregister}CustomFilter

ACR: TWDAPI-274

This is the first part of the implementation of nnstreamer's pipeline
CustomFilter Web API. It enables registering and unregistering
CustomFilters, but they don't process the data.

[Verification] Tested with the snippets below, works fine

var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenPlusOne = function(input) {
    console.log("Custom filter called with: ");
    var outputTD = outputTI.getTensorsData();
    var rawInputData = input.getTensorRawData(0);
    for (var i = 0; i < rawInputData.data.size; ++i) {
        rawInputData.data[i] = rawInputData.data[i] + 1;
    }
        outputTD.setTensorRawData(0, rawInputData.data);
        return new tizen.ml.CustomFilterOutput(0, outputTD);
}

// register - the happy scenario
tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})
// READY
pipeline.start()

// unregister - the happy scenario
tizen.ml.pipeline.unregisterCustomFilter('testfilter2')

// overwrite a previously registered filter - that's ok

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenPlusOne, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

// unregister nonexistent filter
tizen.ml.pipeline.unregisterCustomFilter('nonexistentfilter')
// InvalidValuesError: ""nonexistentfilter" CustomFilter not found"

Change-Id: Ib01490e669376149eae654937131116f5ec1a4df
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
3 years agoCheck thread smack label for thread-based app model 65/254065/7 submit/tizen/20210223.072943
Youngsoo Choi [Mon, 22 Feb 2021 23:42:09 +0000 (15:42 -0800)]
Check thread smack label for thread-based app model

Legacy web service app had been launched on a process but
new web service app is launched on a thread to save memory usage.
With the thread-based app model, the thread smack label needs to be checked
from the path |/proc/<tid>/attr/current|.

Also, checking thread smack label is compatible with process-based app model
because main thread utilizes same path of |/proc/<pid>/attr/current| as well.

Change-Id: Ib02237c926a2deedcd91451a36dd2a3d832cfb04
Signed-off-by: Youngsoo Choi <kenshin.choi@samsung.com>
3 years agoMerge "[Mediakey] Conditional support for module" into tizen
Piotr Kosko [Mon, 22 Feb 2021 14:53:57 +0000 (14:53 +0000)]
Merge "[Mediakey] Conditional support for module" into tizen