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 - Can't create handler inside thread Thread[AsyncTask] that has not called Looper.prepare #142

Closed
Catfriend1 opened this issue Dec 18, 2018 · 1 comment
Assignees
Labels
bug skip-changelog Related to unreleased code
Milestone

Comments

@Catfriend1
Copy link
Owner

Description of the issue

Introduced while working on PR #135 "Refactor ConfigXml"

Android Log

2018-12-18 12:06:30.327 14809-15221/com.github.catfriend1.syncthingandroid.debug V/SyncthingService: importConfig: Importing index database
2018-12-18 12:06:30.375 14809-15221/com.github.catfriend1.syncthingandroid.debug V/SyncthingService: importConfig END
2018-12-18 12:06:30.376 14809-15221/com.github.catfriend1.syncthingandroid.debug V/SyncthingService: Starting syncthing
2018-12-18 12:06:30.376 14809-15221/com.github.catfriend1.syncthingandroid.debug V/SyncthingService: onServiceStateChange: from DISABLED to STARTING
2018-12-18 12:06:30.376 14809-15221/com.github.catfriend1.syncthingandroid.debug D/ConfigXml: Parsing config file '/data/user/0/com.github.catfriend1.syncthingandroid.debug/files/config.xml'
2018-12-18 12:06:30.376 14809-14809/com.github.catfriend1.syncthingandroid.debug V/NotificationHandler: Starting foreground service or updating notification
2018-12-18 12:06:30.385 14809-15221/com.github.catfriend1.syncthingandroid.debug I/ConfigXml: Successfully parsed config file
2018-12-18 12:06:30.385 14809-15221/com.github.catfriend1.syncthingandroid.debug I/ConfigXml: Found existing config version 28
2018-12-18 12:06:30.388 14809-15221/com.github.catfriend1.syncthingandroid.debug I/SyncthingService: Web GUI will be available at https://127.0.0.1:8384
2018-12-18 12:06:30.430 14809-15221/com.github.catfriend1.syncthingandroid.debug D/SyncthingRunnable: killSyncthing: Found no running instances of libsyncthing.so
CRASH
2018-12-18 12:06:30.433 14809-15221/com.github.catfriend1.syncthingandroid.debug E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
Process: com.github.catfriend1.syncthingandroid.debug, PID: 14809
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:354)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.RuntimeException: Can't create handler inside thread Thread[AsyncTask #2,5,main] that has not called Looper.prepare()
at android.os.Handler.(Handler.java:205)
at android.os.Handler.(Handler.java:118)
at com.nutomic.syncthingandroid.http.PollWebGuiAvailableTask.(PollWebGuiAvailableTask.java:28)
at com.nutomic.syncthingandroid.service.SyncthingService.launchStartupTask(SyncthingService.java:488)
at com.nutomic.syncthingandroid.service.SyncthingService.importConfig(SyncthingService.java:955)
at com.nutomic.syncthingandroid.activities.SettingsActivity$SettingsFragment$ImportConfigTask.doInBackground(SettingsActivity.java:713)
at com.nutomic.syncthingandroid.activities.SettingsActivity$SettingsFragment$ImportConfigTask.doInBackground(SettingsActivity.java:696)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:764)

@Catfriend1 Catfriend1 added bug skip-changelog Related to unreleased code labels Dec 18, 2018
@Catfriend1 Catfriend1 added this to the 0.14.55 milestone Dec 18, 2018
@Catfriend1 Catfriend1 self-assigned this Dec 18, 2018
@Catfriend1
Copy link
Owner Author

Solved by commit #73c5017

Catfriend1 pushed a commit that referenced this issue Dec 22, 2018
Changelog:
- "Use default folder path given in config.xml" (#101)
- "IllegalStateException: Fragment already added" (#108)
- "Enhancement request for per-folder(device) sync conditions" (#110)
- "NPE crash after key and config regeneration" (#141)
- "Adjust the folder icon to show if it's send/receive or both" (#143)
- "CPU percentage is not shown on the status tab" (#144)
- "Always make individual sync conditions UI available" (#145)
- "IntroducedBy deviceID lost on config change through wrapper UI" (#146)
- "Wrapper doesn't use the same syntax as syncthing core's web UI for device addresses" (#147)
- "Syncthing wrapper "emergency" shutdown on native binary crash doesn't work" (#148)

Commits:

* WIP

* WIP

* Get folder list and paused setting when syncthing is not running

Preparation to solve #110

* Fix NPE in DeviceListFragment#DEVICES_COMPARATOR

* Remove blank line

* Add ConfigXml#getDevices and comparator

Make ConfigXml#saveChanges public

* SyncthingService evaluates per folder/device

sync conditions when syncthing is not running via ConfigXml

* Fix typos and add stubs

* Fix build errors

* DEBUG - Always run syncthing binary

* Fix NPE at RunConditionMonitor pointer

* Add setFolderPause, setDevicePause

to ConfigXml

* Improve logging

* Remove test mode

* Better log levels

* Make ConfigXml#updateIfNeeded private

* Remove SyncthingService#mStartupTask

AsyncTask no longer needed

* Update model/Options (fixes #101)

* Fix NPE after config regeneration (fixes #140)

* Refactor key and config generation

Refactor ConfigXml public functions to allow checking if a valid config exists and trigger key and config (re)genration if something is corrupted.

* Fix crash on export/import (fixes #142)

* ApiRequest - Disable verbose log in release builds

* ConfigXml#updateIfNeeded - Disable "startBrowser"

because it applies to desktop environments and cannot start a mobile browser app

* MainActivity - Always show all tabs

* Show folder/device tab contents from config.xml

if syncthing is not running

* Update ConfigXml#getDevices return model

- compression
- introducer

* Device tab - Hide in/out rate if syncthing is not running

 or if the device is paused

* Update device item layout

* MainActivity/Devices - Prevent showing outdated status

after syncthing core transitioned from "active" to "disabled"

* MainActivity/Folders - Prevent showing outdated status

after syncthing core transitioned from "active" to "disabled"

* Add ConfigRouter class

Provides a transparent access to the config if ...
a) Syncthing is running and REST API is available.
b) Syncthing is NOT running and config.xml is accessed.

* Add pref - Cache local device ID

* Allow excluding self in ConfigRouter#getDevices

* Allow excluding self in ConfigRouter#getDevices (2)

* Update Folder model default values

* Update Folder model defaults (2)

- copiers
- hashers

* WIP - ConfigXml - FolderActivity

Remove unused pref inject code
Cache local device ID in pref
Reduce verbose logging in release builds
Extend ConfigXml#getFolders
Extend ConfigXml#getDevices
Fix ConfigXml#setDevicePause

ToDo ConfigXml#getFolderIgnoreList needs to be implemented

* Implemented ConfigXml#getFolderIgnoreList

* Extend ConfigXml#getDevices

- device.addresses

* WIP - DeviceActivity

Make it available when syncthing is not running

* Fix unsuccessful API bumps while syncthing is starting

* Fix space

* Adjust the folder icon to show if it's send/receive or both (fixes #143)

* Fix lint - item_device_list

* Preserve active tab when syncthing core transitions between running and not running

* Add xmlns:android to item_folder_list

* Remove unused reference from item_folder_list

* Add device icon to device tab

* Fix CPU percentage not showing (fixes #144)

* SyncthingService - Polish iterator code

* Fix MainActivity#updateViewPager (fixes #108)

* Add ConfigXml#updateFolder, updateDevice (1)

* Add ConfigRouter#updateFolder, updateDevice

* Add missing "final" to ConfigXml#updateDevice

* WIP - FolderActivity - Update updateFolder via ConfigRouter

ToDo: Implement ConfigRouter here.

* ConfigRouter - Fix missing return

* DeviceActivity - Update device via ConfigRouter

* Always make individual sync conditions UI available (fixes #145)

regardless if syncthing core is running or not.
Remove SyncthingService dependency from SyncConditionsActivity

* Fix incorrect folder type icon shown

when syncthing core is not running

* Add "introducedBy" to folder and device model (fixes #146)

* Add Folder#getDevices to model

* ConfigXml#updateFolder - Writeback devices sharing the folder

Support preserving the "introducedBy" model field of Folder.java (fixes #146)

* Add ConfigXml#updateFolder - Versioning

* Remove SyncthingService dependency from FolderPickerActivity

because it is no longer required.

* Update ToDo remarks

* Add ConfigXml#updateDevice - Addresses

* Fix DeviceActivity#persistableAddresses to be more graceful (fixes #147)

and accept the same address syntax as syncthing core web UI does.

* Add ConfigXml#removeFolder, removeDevice

* Add ConfigXml#addDevice, addFolder

- Add ConfigXml#isDeviceIdValid
- Do not allow adding empty folder labels or empty device names.
- Update model Folder.java so ConfigXml can handle the ignorePerms XML attribute

* Fix Syncthing wrapper "emergency" shutdown on native binary crash (fixes #148)

* Update translation de

* Add ConfigXml#postFolderIgnoreList

* Update APK version to 0.14.54.3 / 4182

* Revert DEBUG - Always run syncthing binary

* Update whatsnew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug skip-changelog Related to unreleased code
Projects
None yet
Development

No branches or pull requests

1 participant