Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Problem with UIImageWriteToSavedPhotosAlbum #109

Open
tobiAdBr opened this issue Apr 7, 2021 · 0 comments · Fixed by #116
Open

Problem with UIImageWriteToSavedPhotosAlbum #109

tobiAdBr opened this issue Apr 7, 2021 · 0 comments · Fixed by #116

Comments

@tobiAdBr
Copy link

tobiAdBr commented Apr 7, 2021

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"
  }
Logikgate added a commit to Logikgate/ns-v8ios-runtime that referenced this issue Apr 12, 2021
rigor789 pushed a commit that referenced this issue Apr 13, 2021
NathanWalker pushed a commit that referenced this issue Jul 3, 2021
* fix: don't allocate persistent empty objects

* fix: Blocks memory leak (#100)

* feat: drop custom WeakRef implementation & use built-in

* fix: free allocated memory in ReferenceWrapper

* fix: DictionaryAdapter Hanging References (#114)

* Clean up hanging references before deallocating

Reduces total dictionary related memory leaks by 36%

* fix

* chore: more leak fixes

* fix: only release enumerator_ when set (#117)

* fix: handle methods with pointer type params

fixes #109

* fix: referenceWrapper memory leak & CString leak

* refactor: ReferenceWrapper dispose to be managed internally

* fix: pre-allocate memory even for empty values

* fix: undo invalid fix (needs a different way)

Co-authored-by: Darin Dimitrov <[email protected]>
Co-authored-by: Bryse Meijer <[email protected]>
Co-authored-by: logikgate <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant