Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19773] iOS: Sample app crashes on start with SQLite error related to analytics

GitHub Issuen/a
TypeStory
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2016-08-09T21:35:34.000+0000
Affected Version/sRelease 5.1.0
Fix Version/sRelease 5.4.0
ComponentsiOS
Labelsanalytics
ReporterFokke Zandbergen
AssigneeChee Kiat Ng
Created2015-10-23T06:24:34.000+0000
Updated2017-11-15T19:57:37.000+0000

Description

After a few successful builds to my iPhone 6S the new [3D Touch Sample App](https://github.com/appcelerator-developer-relations/appc-sample-3dtouch) started crashing when launched. The only way to fix it was to remove the app and then redeploy it. Replacing the app with a new build without removing it didn't resolve it. A full crash log attached, which makes it more clear this is related to our analytics. Our analytics should me as fool-proof as we can make it. We should catch all exceptions to prevent the app from crashing even though that means analytics is no longer working. *Console*
-- Start application log -----------------------------------------------------
[DEBUG] Reading stylesheet from: /var/mobile/Containers/Bundle/Application/9A562E87-3A7A-47B9-A9D7-F2B7FD09BFB4/3D Touch.app/stylesheet.plist
[INFO]  3D Touch/1.0.0 (5.1.0.c5877a0)
[DEBUG] Loading: /var/mobile/Containers/Bundle/Application/9A562E87-3A7A-47B9-A9D7-F2B7FD09BFB4/3D Touch.app/app.js, Resource: app_js
[ERROR] Error occurred calling next on a PLSqliteResultSet. SQLite error: 'database disk image is malformed' for 'SELECT * from event_sequence'
[DEBUG] Loading: /var/mobile/Containers/Bundle/Application/9A562E87-3A7A-47B9-A9D7-F2B7FD09BFB4/3D Touch.app/alloy.js, Resource: alloy_js
[ERROR] The application has crashed with an uncaught exception 'PLSqliteException'.
[ERROR] Reason:
[ERROR] occurred calling next on a PLSqliteResultSet. SQLite error: 'database disk image is malformed' for 'SELECT * from event_sequence'
[ERROR] Stack trace:
[ERROR]
[ERROR] 0   CoreFoundation                      0x000000018296cf5c <redacted> + 124
[ERROR] 1   libobjc.A.dylib                     0x0000000197e5bf80 objc_exception_throw + 56
[ERROR] 2   CoreFoundation                      0x000000018296cea4 <redacted> + 0
[ERROR] 3   3D Touch                            0x000000010050ed94 3D Touch + 4517268
[ERROR] 4   3D Touch                            0x0000000100509628 3D Touch + 4494888
[ERROR] 5   libdispatch.dylib                   0x0000000198649770 <redacted> + 16
[ERROR] 6   libdispatch.dylib                   0x00000001986549c4 <redacted> + 100
[ERROR] 7   3D Touch                            0x0000000100509548 3D Touch + 4494664
[ERROR] 8   3D Touch                            0x000000010050a2d0 3D Touch + 4498128
[ERROR] 9   3D Touch                            0x000000010050c2bc 3D Touch + 4506300
[ERROR] 10  libdispatch.dylib                   0x00000001986497b0 <redacted> + 24
[ERROR] 11  libdispatch.dylib                   0x0000000198649770 <redacted> + 16
[ERROR] 12  libdispatch.dylib                   0x000000019865575c <redacted> + 864
[ERROR] 13  libdispatch.dylib                   0x000000019864d274 <redacted> + 464
[ERROR] 14  libdispatch.dylib                   0x0000000198649770 <redacted> + 16
[ERROR] 15  libdispatch.dylib                   0x0000000198657bb0 <redacted> + 2140
[ERROR] 16  libdispatch.dylib                   0x000000019865734c <redacted> + 112
[ERROR] 17  libsystem_pthread.dylib             0x000000019885d478 _pthread_wqthread + 1092
[ERROR] 18  libsystem_pthread.dylib             0x000000019885d028 start_wqthread + 4
[ERROR] *** Terminating app due to uncaught exception 'PLSqliteException', reason: 'Error occurred calling next on a PLSqliteResultSet. SQLite error: 'database disk image is malformed' for 'SELECT * from event_sequence''
[ERROR] *** First throw call stack:
[ERROR] (0x18296cf5c 0x197e5bf80 0x18296cea4 0x10050ed94 0x100509628 0x198649770 0x1986549c4 0x100509548 0x10050a2d0 0x10050c2bc 0x1986497b0 0x198649770 0x19865575c 0x19864d274 0x198649770 0x198657bb0 0x19865734c 0x19885d478 0x19885d028)
^C
Fokkes-MacBook-Pro:appc-sample-3dtouch fokkezb$ tn iphone-fokke

-- End application log -------------------------------------------------------

Attachments

FileDateSize
3D Touch 23-10-15 07-58.crash2015-10-23T06:24:32.000+000065606

Comments

  1. Hans Knöchel 2015-11-04

    [~fokkezb] Are sure sure it is related to analytics and not an error of your models?
  2. Fokke Zandbergen 2015-11-05

    It might be the models that somehow caused the database disk to be malformed, but the query showing is form analytics: https://github.com/appcelerator/aps_sdk/blob/0a79bba287b4b9a2cbcca46d584634035db9c49f/ios/support/analytics/APSAnalytics/APSAnalytics.m#L599 The analytics module (and others we might inject) should never cause the app to crash. We should catch this, warn maybe but not crash.
  3. Mark Henderson 2015-11-20

    This is extremely serious this is happening in my production app. I am getting phone call around from around the world that they have unsynchronised work and the app will not open for them to synchronise (my app runs offline for the Construction industry). [INFO] : *AppNameRemoved*/4.124.4 (5.0.2.92c2265) [DEBUG] : Loading: /var/mobile/Containers/Bundle/Application/9A26E98C-C9A0-4221-9274-E9ABEC559180/AppNameRemoved.app/app.js, Resource: app_js [ERROR] : The application has crashed with an uncaught exception 'PLSqliteException'. [ERROR] : Reason: [ERROR] : Attempted to access non-NSString * column as NSString *. [ERROR] : Stack trace: [ERROR] : [ERROR] : 0 CoreFoundation 0x000000018621cf48 + 124 [ERROR] : 1 libobjc.A.dylib 0x000000019ae8ff80 objc_exception_throw + 56 [ERROR] : 2 CoreFoundation 0x000000018621ce90 + 0 [ERROR] : 3 AppNameRemoved 0x00000001005da92c AppNameRemoved + 5744940 [ERROR] : 4 AppNameRemoved 0x00000001005d3948 AppNameRemoved + 5716296 [ERROR] : 5 libdispatch.dylib 0x000000019b6a16a8 + 16 [ERROR] : 6 libdispatch.dylib 0x000000019b6ac954 + 100 [ERROR] : 7 AppNameRemoved 0x00000001005d3850 AppNameRemoved + 5716048 [ERROR] : 8 AppNameRemoved 0x00000001005d78a4 AppNameRemoved + 5732516 [ERROR] : 9 libdispatch.dylib 0x000000019b6a16e8 + 24 [ERROR] : 10 libdispatch.dylib 0x000000019b6a16a8 + 16 [ERROR] : 11 libdispatch.dylib 0x000000019b6ad6ec + 864 [ERROR] : 12 libdispatch.dylib 0x000000019b6a51ac + 464 [ERROR] : 13 libdispatch.dylib 0x000000019b6af5bc + 728 [ERROR] : 14 libdispatch.dylib 0x000000019b6af2dc + 112 [ERROR] : 15 libsystem_pthread.dylib 0x000000019b8c1470 _pthread_wqthread + 1092 [ERROR] : 16 libsystem_pthread.dylib 0x000000019b8c1020 start_wqthread + 4 [ERROR] : *** Terminating app due to uncaught exception 'PLSqliteException', reason: 'Attempted to access non-NSString * column as NSString *.' [ERROR] : *** First throw call stack: [ERROR] : (0x18621cf48 0x19ae8ff80 0x18621ce90 0x1005da92c 0x1005d3948 0x19b6a16a8 0x19b6ac954 0x1005d3850 0x1005d78a4 0x19b6a16e8 0x19b6a16a8 0x19b6ad6ec 0x19b6a51ac 0x19b6af5bc 0x19b6af2dc 0x19b8c1470 0x19b8c1020) [TRACE] : Uploaded tiapp metadata with Appcelerator Platform!
  4. Hans Knöchel 2015-11-20

    [~mark.henderson@snagr.co.uk] That issue does not look like the above described one. Attempted to access non-NSString * column as NSString * indicates, that you tried to access a value as string although it isn't. Also note, that this issue seems related to 5.1.0, which is not released, yet. But we still want to fix this, can you track this down to a part of your app and provide demo code to reproduce? EDIT: If you use Ti.Database sql (not alloy models as the above issue), please follow [this guide](http://www.dosomethinghere.com/2013/02/20/fixing-the-sqlite-error-the-database-disk-image-is-malformed/) to repair your sqlite database, it has been recommended by the native ios community as well.
  5. Mark Henderson 2015-11-20

    @Hans, this isn't in my app code, it happens immediately.. This is why I think it is related to this issue. To test I stopped loading my normal window and instead get app.js to load a blank window.. Same problem, immediate crash: - Start application log ----------------------------------------------------- [DEBUG] : Reading stylesheet from: /var/mobile/Containers/Bundle/Application/D8EC395A-ABB6-4C93-ACB4-FAAC20D9BC6E/xxxx.app/stylesheet.plist [DEBUG] : - changing property masksToBounds in transform-only layer, will have no effect [DEBUG] : - changing property masksToBounds in transform-only layer, will have no effect [DEBUG] : - changing property masksToBounds in transform-only layer, will have no effect [INFO] : xxxx/4.124.4 (5.0.2.92c2265) [DEBUG] : Loading: /var/mobile/Containers/Bundle/Application/D8EC395A-ABB6-4C93-ACB4-FAAC20D9BC6E/xxxx.app/app.js, Resource: app_js [ERROR] : The application has crashed with an uncaught exception 'PLSqliteException'.
  6. Hans Knöchel 2015-11-20

    Alright. Don't get me wrong, we take this of course serious. Can you provide a demo code that only holds the the code that crashes the project? And if is required no code, send the project anyway, along with the exact version you are using. EDIT: Also edited your comment to hide the real app name.
  7. Mark Henderson 2015-11-20

    @Hans, Version 5.0.2GA of the SDK. This has happened on one device only. I was in the middle of a presentation, the iPad wasn't being used or connected to an internet connection at the time and it just randomly crashed. It then wouldn't open at all. I am now briefly back at the office before I have to go to another presentation requiring the iPad. I cannot send my business's app code to you, I also cannot get the iPA off this iPad to send to you, or the corrupted analytics.db or whatever SQLite database Appcelerator might use internally. I can imagine this is the end of the road for being able to help my issue any further. As soon as I remove / re-add the app everything will be fine. If this is the same issue that has been happening to clients then they are losing work removing /re-adding.. :(
  8. Mark Henderson 2015-12-04

    This issue is killing me. I have numerous clients around the world reporting this issue in my production app. I cannot re-create it as I can't cause the initial crash. I'm convinced it's caused by an Appcelerator analytics db because the app will now continue to crash forever on load. This is the worst thing that can happen as my users now have un-synchronised data that cannot be accessed and a dead app that has to be removed and re-added. I am losing a ton of clients over this. I cannot re-create the issue as I don't know when analytics is called or what is causing the initial crash. One thing to note I am a heavy user of SQLite so perhaps there is an open connection to my database and to the analytics db that causes a clash / issue? I don't think the problem is with my code as when the app is launched there is nothing for quite a few windows that uses SQLite in my app, yet it will forever crash on launch. Is there a way to build the app with no analytics.db or something like that?
  9. Matthew Delmarter 2015-12-04

    I had this exact issue on my personal device as reported with the log output: {noformat} [ERROR] Error occurred calling next on a PLSqliteResultSet. SQLite error: 'database disk image is malformed' for 'SELECT * from event_sequence' {noformat} The app crashed immediately upon launching. I saw the log output and guessed that it was the analytics causing the issue, because I do not have an sqlite db in my app. So I went into tiapp.xml and changed the following line from 'true' to 'false'. {noformat} false {noformat} I then rebuilt and updated the app on the device - and the issue was resolved. So @Mark Henderson - just change that line in your app and push out an update to users. If your logged error is the same and indeed caused by the analytics, then this should fix it.
  10. Mark Henderson 2015-12-04

    Thanks @mdelmarter I had just stumbled upon that, so it's great that it's likely to provide a permanent fix!
  11. Chee Kiat Ng 2015-12-17

    PRs here: https://github.com/appcelerator/aps_sdk/pull/283 https://github.com/appcelerator/titanium_mobile/pull/7608
  12. Chee Kiat Ng 2015-12-29

    New analytics PR: https://github.com/appcelerator/aps_sdk/pull/286
  13. Chee Kiat Ng 2016-01-07

    PRs merged.
  14. Aideen Gibson 2016-07-28

    This is a really serious issue - I got the same problem with my App on various testing devices with clients. Really stressed me out. I am using Appcelerator Studio build 4.5.0.201602170821 . @mdelmarter you really saved my life - I changed Analytics to false and rebuilt and installed App on the device without having to remove it! Thank you!
  15. Hans Knöchel 2016-07-28

    Hey AIdeen, the better that it has been fixed. Did you try the latest 5.4.0 build, yet to verify it works now?
  16. Harry Bryant 2016-08-08

    Attempted to recreate the crash, but was unable to do so, even after 20 launch attempts. [~aideengibson@yahoo.co.uk] are you able to verify whether the latest 5.4.0 build has fixed the issue? it would be greatly appreciated to receive your feedback. Tested On: iPhone 6S (9.3.3) Device & iPhone 6 Plus (8.3) Device Mac OSX El Capitan 10.11.6 Ti SDK: 5.4.0.v20160804185318 Appc Studio: 4.7.0.201607250649 Appc NPM: 4.2.7 App CLI: 5.4.0-40 Xcode 7.3.1 Node v4.4.7
  17. Harry Bryant 2016-08-09

    Closing this ticket as unable to reproduce, If you are still experiencing this issue, please leave a comment and we will reopen the ticket for further investigation.
  18. Ian Taylor 2017-07-11

    I've recently encountered this same issue with a production iOS app. The app was crashing on start-up on just some devices. I spotted this in the device log: Thread 2 name: Dispatch queue: com.appcelerator.anlaytics.databaseQueue Thread 2 Crashed: And this in a console log: [ERROR] The application has crashed with an uncaught exception 'PLSqliteException'. Reason: Attempted to access non-NSString * column as NSString *. Disabling analytics as described above solved the problem! The app does use a database, but to try and rule this out I replaced my normal start-up code with a very basic window. It didn't help. One other (strange?) thing I noticed: 1. Close the app from multi-tasking 2. Try to open the app (it crashes) 3. Look at the app in multi-tasking - you see the window which was open when the app was last running successfully (which is not the same window as when the app first opens). So closing the app from multi-tasking didn't seem to actually close it..? May be related, or may not be.
  19. Rene Pot 2017-11-15

    Managed to reproduce, also disabled analytics and it works. I have the database file in question locally, I'll try to attach it
  20. Rene Pot 2017-11-15

    I seem not to be able to upload a file here, I have it with SDK 6.3.0 on a recent file. I too use a local SQLite file, but disabling analytics did the trick for me. When in need of the file, please just contact me and I can email it.
  21. Rene Pot 2017-11-15

    My trace: [code] [ERROR] : The application has crashed with an uncaught exception 'PLSqliteException'. [ERROR] : Reason: [ERROR] : Attempted to access non-NSString * column as NSString *. [ERROR] : Stack trace: [ERROR] : 0 CoreFoundation 0x0000000181bd9d04 + 124 [ERROR] : 1 libobjc.A.dylib 0x0000000180e28528 objc_exception_throw + 56 [ERROR] : 2 CoreFoundation 0x0000000181bd9c4c + 0 [ERROR] : 3 Stapler 0x0000000102e32f30 Stapler + 4190000 [ERROR] : 4 Stapler 0x0000000102e2b948 Stapler + 4159816 [ERROR] : 5 libdispatch.dylib 0x000000018155d048 + 16 [ERROR] : 6 libdispatch.dylib 0x0000000181599ea8 + 56 [ERROR] : 7 Stapler 0x0000000102e2b850 Stapler + 4159568 [ERROR] : 8 Stapler 0x0000000102e2ff18 Stapler + 4177688 [ERROR] : 9 libdispatch.dylib 0x000000018155d088 + 24 [ERROR] : 10 libdispatch.dylib 0x000000018155d048 + 16 [ERROR] : 11 libdispatch.dylib 0x000000018159b1c0 + 520 [ERROR] : 12 libdispatch.dylib 0x000000018159bb30 + 340 [ERROR] : 13 libdispatch.dylib 0x000000018159c528 + 380 [ERROR] : 14 libdispatch.dylib 0x00000001815a45c4 + 640 [ERROR] : 15 libsystem_pthread.dylib 0x0000000181802fd0 _pthread_wqthread + 932 [ERROR] : 16 libsystem_pthread.dylib 0x0000000181802c20 start_wqthread + 4 -- End application log ------------------------------------------------------- [code]
  22. Rene Pot 2017-11-15

    sqlite file: https://www.dropbox.com/s/fohtcnttoobjxor/analytics.db?dl=0

JSON Source