Registry Mirror
Skip to content

Problem with UIImageWriteToSavedPhotosAlbum #109

Open

Description

@tobiAdBr

Hey there I encountered a problem when calling UIImageWriteToSavedPhotosAlbum with a completionTarget. This error does not appear if I use "@nativescript/ios": "6.5.4", instead of "@nativescript/ios": "7.2.0".

I also tried to use the Typescript Subclassing Syntax without any success.

Error:

====== Assertion failed ======
Native stack trace:
1          0x10f628630 tns::Assert(bool, v8::Isolate*) + 119
2          0x10f620d3d tns::ClassBuilder::GetTypeEncodingType(v8::Isolate*, v8::Local<v8::Value>) + 121
3          0x10f61eda7 tns::ClassBuilder::ExposeDynamicMethods(v8::Local<v8::Context>, objc_class*, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::Local<v8::Object>) + 1069
4          0x10f61e93f tns::ClassBuilder::ExposeDynamicMembers(v8::Local<v8::Context>, objc_class*, v8::Local<v8::Object>, v8::Local<v8::Object>) + 219
5          0x10f61def5 tns::ClassBuilder::ExtendCallback(v8::FunctionCallbackInfo<v8::Value> const&) + 459
6          0x10f75fd2c v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) + 620
7          0x10f75f1dc v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) + 556
8          0x10f75e863 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) + 259
9          0x10fff7819 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit + 57
10         0x10ff90842 Builtins_InterpreterEntryTrampoline + 194
JavaScript stack trace:
at saveToAlbum (file: .../image-util.ios.ts:10:46)

Code Snippet:
This implementation is based on this post.

const CompletionTarget = (<any> NSObject).extend({
        'thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:': function (image, error, context) {
            if (error) {
                console.log("on error", error);
            }
        }
    }, {
        exposedMethods: {
            'thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:': {
                returns: interop.types.void,
                params: [UIImage, NSError, interop.Pointer]
            }
        }
    });
    const completionTarget = CompletionTarget.alloc().init();
    UIImageWriteToSavedPhotosAlbum(imageSource.ios, completionTarget,'thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:',null);

Calling UIImageWriteToSavedPhotosAlbum without a completionTarget works fine.
UIImageWriteToSavedPhotosAlbum(imageSource.ios, null, null, null);

Setup:

"dependencies": {
    "@angular/animations": "~11.2.7",
    "@angular/common": "~11.2.7",
    "@angular/compiler": "~11.2.7",
    "@angular/core": "~11.2.7",
    "@angular/forms": "~11.2.7",
    "@angular/platform-browser": "~11.2.7",
    "@angular/platform-browser-dynamic": "~11.2.7",
    "@angular/router": "~11.2.7",
    "@nativescript/angular": "~10.0.0",
    "@nativescript/core": "7.3.0",
    "@nativescript/unit-test-runner": "^1.0.2",
    "core-js": "3.9.0",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.5.5",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.1102.6",
    "@angular/cli": "~11.2.6",
    "@angular/compiler-cli": "~11.2.7",
    "@nativescript/android": "7.0.1",
    "@nativescript/ios": "7.2.0",
    "@nativescript/types": "7.3.0",
    "@nativescript/webpack": "~3.0.0",
    "@ngtools/webpack": "~10.0.0",
    "@types/jasmine": "~3.6.0",
    "codelyzer": "^6.0.0",
    "karma": "6.3.1",
    "karma-jasmine": "~4.0.0",
    "karma-nativescript-launcher": "0.4.0",
    "karma-webpack": "3.0.5",
    "node-sass": "^4.7.1",
    "tslint": "~6.1.3",
    "typescript": "4.1.5"
  }

Activity

  1. added a commit that references this issue on Apr 12, 2021
    832c01a
  2. added a commit that references this issue on Apr 13, 2021
    7be3d61
  3. added 2 commits that reference this issue on Jul 3, 2021
    a84ae27
    431e816
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions