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

Crash on iOS Device #139

Open
michitosh opened this issue Apr 29, 2021 · 9 comments
Open

Crash on iOS Device #139

michitosh opened this issue Apr 29, 2021 · 9 comments

Comments

@michitosh
Copy link

michitosh commented Apr 29, 2021

The App crashes on iOS when FileUpload Instance tries to start more then one payload at once.

If only one payload is started or if I wait 10 Secunds until I init the second payload everything works fine.
Uploader is set to {parallelUploadsLimit: 5}

Below I've added the log from XCode.
I verified that the Files are stored and can be accessed.

This is an example file path:
file:///var/mobile/Containers/Data/Application/54190526-4123-40BC-AC1C-80914BF94EEA/Library/files/my_folder/1619733997937.jpg

2021-04-29 18:08:46.639513+0200 GEOPLORE[5587:1210933] will start <FileUpload: 0x28080fc60> {stopped, DA931839-EC8C-435C-9B8C-754F4472DAE8}
2021-04-29 18:08:46.645780+0200 GEOPLORE[5587:1210933] will save mutable info for <FileUpload: 0x28080fc60> {started, DA931839-EC8C-435C-9B8C-754F4472DAE8}
2021-04-29 18:08:46.647102+0200 GEOPLORE[5587:1210933] did start <FileUpload: 0x28080fc60> {started, DA931839-EC8C-435C-9B8C-754F4472DAE8}
2021-04-29 18:08:46.647147+0200 GEOPLORE[5587:1210933] THREAD WARNING: ['FileTransferBackground'] took '89.150879' ms. Plugin should use a background thread.
2021-04-29 18:08:46.647807+0200 GEOPLORE[5587:1210933] -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xa14ceb37ed38b2c9
2021-04-29 18:08:46.649332+0200 GEOPLORE[5587:1210933] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xa14ceb37ed38b2c9'
*** First throw call stack:
(0x18d1d3128 0x1a0ee6480 0x18d0e2138 0x18d1d5784 0x18d1d79ac 0x1047bbe4c 0x1047b8e34 0x104948070 0x10494f784 0x104950aac 0x198de0300 0x198fdd0e4 0x199237774 0x199236e58 0x198bdc2ec 0x198f2f8f4 0x198bbe7a4 0x198bbe0b8 0x196c85478 0x196c86270 0x18d152780 0x18d152680 0x18d1519d4 0x18d14bef0 0x18d14b6a8 0x1a37fb570 0x18fa69370 0x18fa6e8ec 0x104655f6c 0x18ce2a140)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xa14ceb37ed38b2c9'
terminating with uncaught exception of type NSException

@azharbeebeejaun
Copy link
Contributor

Hi @michitosh,

Could you provide more details on the iOS version and device used? And how the plugin has been initialized and is being used in the code? We might not be getting into this debug right now but a PR with the necessary fixes will be most welcome and greatly appreciated.

Thanks,
Azhar

@michitosh
Copy link
Author

michitosh commented Apr 30, 2021

Hi @azharbeebeejaun ,

Cordova v10.0.0
Cordova iOS v6.2.0
iPhone X iOS 14.5

The Plugin is initialized in the device ready listener:

`document.addEventListener('deviceready', function () {
uploader = FileTransferManager.init({
parallelUploadsLimit: 5
});
uploader.on('success', function (upload) {
uploader.removeUpload(upload.id, function () {
//upload aborted
}, function (err) {
//could abort the upload
});
});

[...]

});`

The payload is added like this:

db.executeSql('SELECT * FROM XXXX WHERE draft_id=?', [SQLiteId], function (rs) {
var payload = {
"id": rs.rows.item(i).id,
"filePath": rs.rows.item(i).imagepath,
"fileKey": "file",
"serverUrl": postlink + "api/" + api_version + "/Upload",
"showNotification": true,
"notificationTitle": language[lang].lang_upload_progress,
"headers": {
"X-ACTION": "media-upload",
"AUTHTOKEN": userdata.auth
},
"parameters": {
"gp_id": DraftId,
"fileName": uploadFileName
}
};
uploader.startUpload(payload);
}, function (error) {
console.log('UPDATE error: ' + error.message);
});

@matheuscas
Copy link

I've just got the same issue. The iOS version is the 16.1.1 on a iPhone 13 Pro Max. Here's the error and how is initialized and used.

Error:

2022-11-29 18:19:40.271807-0300 App[7123:1776752] -[App.AppDelegate backgroundCompletionBlock]: unrecognized selector sent to instance 0x280576600
2022-11-29 18:19:40.272866-0300 App[7123:1776752] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[App.AppDelegate backgroundCompletionBlock]: unrecognized selector sent to instance 0x280576600'
*** First throw call stack:
(0x1af075e88 0x1a83a38d8 0x1af1ea84c 0x1b1f785ec 0x1af08bfa0 0x1af0f4350 0x1044ecb2c 0x1044f1c10 0x1a94f32f0 0x1a94c74a0 0x1a94c7430 0x1a94887d8 0x1a948850c 0x1a948dc20 0x10479f1d0 0x10478e05c 0x10479e810 0x10479e354 0x1af1066f8 0x1af0e8058 0x1af0eced4 0x1e83ea368 0x1b15cb3d0 0x1b15cb034 0x104028f74 0x1cd754960)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[App.AppDelegate backgroundCompletionBlock]: unrecognized selector sent to instance 0x280576600'
terminating with uncaught exception of type NSException

Init:

uploader = BackgroundUpload.init({
                callBack: event => {
                    console.log(event);
                    switch (event.state) {
                        case 'UPLOADING':
                            console.log('Still uploading')
                            break
                        case 'UPLOADED':
                            console.log('upload done')
                            break
                        case 'FAILED':
                            if (event.id) {
                                console.log("upload: " + event.id + " has failed");
                            } else {
                                console.error("uploader caught an error: " + event.error);
                            }
                    }

                    if (event.eventId) {
                        console.log('Event done and ACK')
                        uploader.acknowledgeEvent(event.eventId)
                    }
                }
            })

How is used:

for (const photo of photos) {
            const payload: FTMPayloadOptions = {
                id: uuidv4(),
                filePath: photo.filepath,
                fileKey: "file",
                serverUrl: serverUrl,
                notificationTitle: "Uploading images",
            };
            uploader.startUpload(payload);
        }

The upload works fine, but at the end, the error message is presented and the app freezes/crashes.

@zfir
Copy link
Member

zfir commented Nov 30, 2022

Hello @matheuscas ,

Can you send me your version of background upload you are using.

@matheuscas
Copy link

Hey @zfir , thanks for asking, here my dependencies:

  "dependencies": {
    **"@awesome-cordova-plugins/background-upload": "^6.2.0",**
    **"@awesome-cordova-plugins/core": "^6.2.0",**
    "@capacitor/android": "^4.0.0",
    "@capacitor/camera": "^4.0.0",
    "@capacitor/core": "^4.0.0",
    "@capacitor/filesystem": "^4.0.0",
    "@capacitor/ios": "^4.0.0",
    "@capacitor/preferences": "^4.0.1",
    "@ionic/pwa-elements": "^3.1.1",
    "@ionic/react": "^5.0.7",
    "@ionic/react-router": "^5.0.7",
    "@testing-library/jest-dom": "^5.5.0",
    "@testing-library/react": "^10.0.2",
    "@testing-library/user-event": "^10.0.1",
    "@types/jest": "^25.2.1",
    "@types/node": "^13.11.1",
    "@types/react": "^16.9.34",
    "@types/react-dom": "^16.9.6",
    "@types/react-router": "^5.1.5",
    "@types/react-router-dom": "^5.1.4",
    "@types/uuid": "^9.0.0",
    **"cordova-plugin-background-upload": "^1.1.0",**
    "ionicons": "^5.0.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router": "^5.1.2",
    "react-router-dom": "^5.1.2",
    "typescript": "^3.8.3",
    "uuid": "^9.0.0"
  },

@zfir
Copy link
Member

zfir commented Nov 30, 2022

Hello @matheuscas,

You should install this version :
cordova plugin add @spoonconsulting/cordova-plugin-background-upload

Also make sure the version is 4.0.7, 1.1.0 is outdated.

@matheuscas
Copy link

Hey @zfir , one more information that maybe can help you, I believe. Here the steps:

  • As soon as I press "Upload all" button to upload all photos I lock the phone
  • Everything stays fine until I unlock the phone and get back to the app.
  • After that, I get the above mentioned exception and the app crashes.

I hope that this helps you.

@zfir
Copy link
Member

zfir commented Nov 30, 2022

Hello @matheuscas,

You should install this version : cordova plugin add @spoonconsulting/cordova-plugin-background-upload

Also make sure the version is 4.0.7, 1.1.0 is outdated.

Hello @matheuscas,

Can you try this and let me know if you have the same error

@matheuscas
Copy link

@zfir Problem solved. Since I'm using Capacitor, I npm installed @spoonconsulting/cordova-plugin-background-uploa and cordova-plugin-file rather than adding it using cordova command. The only errors showed after unlocking the phone were below, but they didn't crash the app. Thank you for your help and for your work on this plugin.

To Native Cordova ->  FileTransferBackground acknowledgeEvent FileTransferBackground1259045247 ["options": [x-coredata:///UploadEvent/tC4B2041A-DAE2-429A-ADFD-9139B982F19B10]]
2022-11-30 13:21:21.309004-0300 App[8088:2128155] error deleting UploadEvent <UploadEvent: 0x2828f0550> (entity: UploadEvent; id: 0x280b8e300 <x-coredata:///UploadEvent/tC4B2041A-DAE2-429A-ADFD-9139B982F19B9>; data: {
    data = nil;
}) : Error Domain=NSCocoaErrorDomain Code=134030 "An error occurred while saving." UserInfo={NSAffectedObjectsErrorKey=(
    "<UploadEvent: 0x2828f0550> (entity: UploadEvent; id: 0x280b8e300 <x-coredata:///UploadEvent/tC4B2041A-DAE2-429A-ADFD-9139B982F19B9>; data: {\n    data = nil;\n})"
)}
2022-11-30 13:21:21.309604-0300 App[8088:2128155] error deleting UploadEvent <UploadEvent: 0x28289af30> (entity: UploadEvent; id: 0x280d17fc0 <x-coredata:///UploadEvent/tC4B2041A-DAE2-429A-ADFD-9139B982F19B10>; data: {
    data = nil;
}) : Error Domain=NSCocoaErrorDomain Code=134030 "An error occurred while saving." UserInfo={NSAffectedObjectsErrorKey=(
    "<UploadEvent: 0x2828f0550> (entity: UploadEvent; id: 0x280b8e300 <x-coredata:///UploadEvent/tC4B2041A-DAE2-429A-ADFD-9139B982F19B9>; data: {\n    data = nil;\n})"
)}

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

No branches or pull requests

4 participants