couchbaselabs / TodoLite-PhoneGap

Basic todo list app for Couchbase Lite and PhoneGap
55 stars 27 forks source link

Android: On start Alert syntax error .... ok // then grey screen #5

Open pellekrogholt opened 10 years ago

pellekrogholt commented 10 years ago

pardon if it overlaps with #3 here it goes

log cat

CordovaWebViewClient  D  onPageFinished(file:///android_asset/www/index.html)
   CordovaActivity  D  onMessage(onPageFinished,file:///android_asset/www/index.html)
            D  onMessage(spinner,stop)
 CordovaNetworkManager  D  Connection Type: wifi
      TilesManager  D  Starting TG #0, 0x746a5020
            D  new EGLContext from framework: 746e6230
    GLWebViewState  D  Reinit shader
            D  Reinit transferQueue
    CordovaLog  D  file:///android_asset/www/js/index.js: Line 541 : getURL
       Web Console  I  getURL at file:///android_asset/www/js/index.js:541
      Listener  W  authHeader is null
            W  Unauthorized -- requestCredentials not given or do not match allowed credentials
      dalvikvm  D  GC_CONCURRENT freed 632K, 7% free 9513K/10228K, paused 3ms+1ms, total 16ms
            D  WAIT_FOR_CONCURRENT_GC blocked 14ms
      Listener  W  authHeader is null
            W  Unauthorized -- requestCredentials not given or do not match allowed credentials
      dalvikvm  D  GC_CONCURRENT freed 104K, 4% free 9918K/10228K, paused 2ms+2ms, total 22ms
            D  WAIT_FOR_CONCURRENT_GC blocked 4ms
   CordovaActivity  D  onMessage(spinner,stop)
 CordovaNetworkManager  D  Connection Type: none
   CordovaActivity  D  onMessage(networkconnection,none)
 CordovaNetworkManager  D  Connection Type: none
            D  Connection Type: wifi
   CordovaActivity  D  onMessage(networkconnection,wifi)
 CordovaNetworkManager  D  Connection Type: wifi
....
click ok
....
    CordovaLog  D  file:///android_asset/www/js/index.js: Line 43 : err {}
       Web Console  I  err {} at file:///android_asset/www/js/index.js:43

versions

$ ls plugins/com.couchbase.lite.phonegap/lib/android/
cblite_android_.zip
commons-io-2.0.1.jar
couchbase-lite-android-1.0.0-beta3rc10.jar
couchbase-lite-java-core-1.0.0-beta3rc10.jar
couchbase-lite-java-javascript-1.0.0-beta3rc10.jar
couchbase-lite-java-listener.jar
jackson-core-asl-1.9.2.jar
jackson-mapper-asl-1.9.2.jar
rhino-1.7R3.jar
servlet-2-3.jar
td_collator_so_enhanced.jar
webserver-2-3.jar
...
$ cordova -v
3.4.1-0.1.0
...
$ cd www
$ gitst
...
remote.origin.url=https://github.com/couchbaselabs/TodoLite-PhoneGap.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
commit 3e86235ca40e99eba3786d43df565de3c4b3239d
Author: Chris Anderson <jchris@couchbase.com>
Date:   Mon May 5 15:10:37 2014 -0700

debuggability

devices

lg nexus 4 / android 4.4

tleyden commented 10 years ago

As a first step, move to a more recent build of couchbase lite android:

http://factory.couchbase.com/view/build/view/mobile_dev/view/android/job/build_cblite_android_master/374/artifact/cblite_android_javadocs_0.0.0-374.zip

I am going to remove the beta3rc10 artifacts, since a lot of people are grabbing these and they are out of date. (do you remember where you saw a link to these, so I can update that link?)

tleyden commented 10 years ago

@pellekrogholt sorry, completely ignore what I said.

I see that those jars are referenced here: https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin/blob/master/plugin.xml

and they should work.

tleyden commented 10 years ago

@jchris any idea why he would be getting this error?

Listener  W  authHeader is null
            W  Unauthorized -- requestCredentials not given or do not match allowed credentials
tleyden commented 10 years ago

@pellekrogholt are you seeing the output of this line anywhere in the logs?

https://github.com/couchbaselabs/TodoLite-PhoneGap/blob/master/js/index.js#L541

Is it possible that somehow it's using a previous version of that javascript file? Did you update an existing project or start a brand new project?

jchris commented 10 years ago

That is what will happen if the basic auth credentials aren't sent.

The log line:

    CordovaLog  D  file:///android_asset/www/js/index.js: Line 541 : getURL
       Web Console  I  getURL at file:///android_asset/www/js/index.js:541

is partial b/c the console.log(a, b, c) only logs the first argument to the adb logcat, we aren't seeing the useful output that would help me know what's going on.

There is a new Chrome remote debug tool that will give you deeper inspection and logging capabilities.

Or alternatively, cd www/ && git pull as I just pushed a small change to make that log line more logcat friendly.

Once we have this output it should help us figure out what's going on.

pellekrogholt commented 10 years ago

@tleyden @jchris

thx for your feedback and suggestions (I have to look into the Chrome remote debug thing looks niece thx) and sorry for the slow response - I was on a long weekend - but here it comes:

updated repos - lets ensure we are on the same page:

$ gitst
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=false
remote.origin.url=git@github.com:couchbaselabs/TodoLite-PhoneGap.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
commit f84aeeccae19e5a6d594e598e40290feedf4dc1d
Author: Chris Anderson <jchris@couchbase.com>
Date:   Thu May 15 16:17:27 2014 -0700

logcat friendly logging

lets build the cordova app cli:

$ cordova run android

lets looks at the logcat - there is probably some noize here forgive me for taht:

...
D/audio_hw_primary(  176): out_standby: exit
D/CordovaActivity( 1103): onMessage(spinner,stop)
D/dalvikvm(31682): GC_CONCURRENT freed 2573K, 17% free 17018K/20464K, paused 13ms+8ms, total 68ms
D/Finsky  (31682): [1] 5.onFinished: Installation state replication succeeded.

we get an alert screen "SyntaxError: Unexpected end of input" and click "OK"

D/CordovaLog( 1103): file:///android_asset/www/js/index.js: Line 43 : err {}
I/Web Console( 1103): err {} at file:///android_asset/www/js/index.js:43
D/audio_hw_primary(  176): start_output_stream: enter: usecase(1: low-latency-playback) devices(0x2)
D/audio_hw_primary(  176): select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
D/audio_hw_primary(  176): enable_snd_device: sending audio calibration for snd_device(2) acdb_id(14)
D/ACDB-LOADER(  176): ACDB -> send_afe_cal
D/audio_hw_primary(  176): enable_snd_device: snd_device(2: speaker)
D/audio_hw_primary(  176): enable_audio_route: apply mixer path: low-latency-playback
W/InputMethodManagerService(  538): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@424d08b8 attribute=null, token = android.os.BinderProxy@4288d838
D/audio_hw_primary(  176): start_output_stream: exit
D/audio_hw_primary(  176): out_standby: enter: usecase(1: low-latency-playback)
D/audio_hw_primary(  176): stop_output_stream: enter: usecase(1: low-latency-playback)
D/audio_hw_primary(  176): disable_audio_route: reset mixer path: low-latency-playback
D/audio_hw_primary(  176): disable_snd_device: snd_device(2: speaker)
D/audio_hw_primary(  176): stop_output_stream: exit: status(0)
D/audio_hw_primary(  176): out_standby: exit
makes sense - what to do ?
tleyden commented 10 years ago

Is that an unmodified index.js file or have you made modifications?

tleyden commented 10 years ago

I just tried the following:

Error message: http://cl.ly/image/2a3S3R3g0m3v

Logs:

05-19 22:03:05.671 D/CordovaLog( 1460): file:///android_asset/www/js/index.js: Line 541 : getURL: [false,"http://192122db-2c00-4574-916a-bba415852e37:36356485-e0be-4bc2-b170-ff42fa49c7d5@localhost:5984/"]
05-19 22:03:05.671 I/Web Console( 1460): getURL: [false,"http://192122db-2c00-4574-916a-bba415852e37:36356485-e0be-4bc2-b170-ff42fa49c7d5@localhost:5984/"] at file:///android_asset/www/js/index.js:541
05-19 22:03:05.699 D/dalvikvm( 1460): GC_CONCURRENT freed 595K, 8% free 9154K/9868K, paused 0ms+0ms, total 2ms
05-19 22:03:05.699 D/dalvikvm( 1460): WAIT_FOR_CONCURRENT_GC blocked 2ms
05-19 22:03:05.699 W/Listener( 1460): authHeader is null
05-19 22:03:05.699 W/Listener( 1460): Unauthorized -- requestCredentials not given or do not match allowed credentials
05-19 22:03:05.711 W/Listener( 1460): authHeader is null
05-19 22:03:05.711 W/Listener( 1460): Unauthorized -- requestCredentials not given or do not match allowed credentials
tleyden commented 10 years ago

I verified that the commits that were supposed to make basic auth work are on the release branch:

https://github.com/couchbase/couchbase-lite-java-listener/commit/26dce8c3643d1ccd563279c0ad0ce617ce60ca76 https://github.com/couchbase/couchbase-lite-java-listener/commit/83385266c4a72239d9dbcb118da5b1a19f358486

tleyden commented 10 years ago

Possibly relevant ticket:

http://stackoverflow.com/questions/14550131/http-basic-authentication-issue-on-android-jelly-bean-4-1-using-httpurlconnectio

tleyden commented 10 years ago

Can reproduce on 4.2.2 in genymotion emulator.

Cannot reproduce on 4.4.2 device or genymotion emulator.

tleyden commented 10 years ago

Another possibly relevant bug: https://code.google.com/p/android/issues/detail?id=57026

jchris commented 10 years ago

This looks like it also a related bug: https://code.google.com/p/android/issues/detail?id=10307

tleyden commented 10 years ago

When I connected directly in safari running on android to 127.0.0.1:5984, it prompted me for a basic auth username and password. When I entered the value from the logs, it worked.

TODO: compare the request received from the safari with the one from todolite phonegap by adding logging in the cblite listener.

jchris commented 10 years ago

Running this raw XHR request before any other requests made it work:

        var xmlHttp = new XMLHttpRequest()
        xmlHttp.open( 'GET', url, false )
        xmlHttp.send( null )
        console.log( 'XMLHttpRequest get: ' +  xmlHttp.responseText )
pellekrogholt commented 10 years ago

@jchris with the adjust ^^ 6e6371afb139fcbfb2103643f4c2ac3db6c7e41d it works(TM) thx

pellekrogholt commented 10 years ago

but when looking at it again with chrome dev inspect enabled (still on master head: 6e6371afb139fcbfb2103643f4c2ac3db6c7e41d) - i get the following console errors:

Failed to load resource: the server responded with a status of 412 (Precondition failed) http://ccc8aafe-3add-4698-acfc-222ec0d92d65:bd8035d1-1eb1-4743-ac50-9c04cce9409d@localhost:5984/todo
Failed to load resource: the server responded with a status of 409 (Conflict) http://ccc8aafe-3add-4698-acfc-222ec0d92d65:bd8035d1-1eb1-4743-ac50-9c04cce9409d@localhost:5984/todo/_design%2Ftodo9
Failed to load resource: the server responded with a status of 404 (Not found) http://ccc8aafe-3add-4698-acfc-222ec0d92d65:bd8035d1-1eb1-4743-ac50-9c04cce9409d@localhost:5984/todo/_local%2Fuser

whats up ?

tleyden commented 10 years ago

@pellekrogholt this ticket is getting unwieldy .. can you file a separate ticket for https://github.com/couchbaselabs/TodoLite-PhoneGap/issues/5#issuecomment-45058909?

Include steps to reproduce and also any incorrect behavior you are seeing (if any)

pellekrogholt commented 10 years ago

@tleyden with fresh eyes i tried to reproduce #5 (comment) - which i was not able to reproduce - sorry for the noize... so i'm not creating a new issue ...

tleyden commented 10 years ago

Can the ticket be closed then?

jonrmitchell commented 9 years ago

I hit this same "Unexpected end of input" error just now with Genymotion emulating a Samsung Galaxy Nexus running Android 4.3 (chosen because that's my phone). Issuing the xhr get-before-put still resloves the issue, but that xhr is never getting fired because my userAgent apparently contains the term "Apple": Mozilla/5.0 (Linux; U; Android 4.3; en-us; Google Galaxy Nexus - 4.3 - API 18 - 720x1280_1 Build/JLS36G) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

Is there a more precise regex for the user-agent check that would work better?

vsymguysung commented 8 years ago

I am having this same issue with Galaxy S5 android 5.0.

The following is the logical output

I/chromium(26508): [INFO:library_loader_hooks.cc(120)] Chromium logging enabled: level = 0, default verbosity = 0 W/chromium(26508): [WARNING:resource_bundle.cc(285)] locale_file_path.empty() I/chromium(26684): [INFO:library_loader_hooks.cc(120)] Chromium logging enabled: level = 0, default verbosity = 0 W/chromium(26684): [WARNING:resource_bundle.cc(285)] locale_file_path.empty() W/chromium(26684): [WARNING:data_reduction_proxy_config.cc(423)] SPDY proxy OFF at startup I/chromium(26684): [INFO:CONSOLE(24)] "The key "target-densitydpi" is not supported.", source: file:///android_asset/www/index.html (24) I/chromium(26684): [INFO:CONSOLE(582)] "getURL: [false,"http://356c034d-1ba6-44fe-b599-c7587dbfcb27:d404d28f-91a4-4c32-a23a-d0c224a1a3f6@localhost:5984/"]", source: file:///android_asset/www/js/index.js (582) I/chromium(26684): [INFO:CONSOLE(0)] "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.", source: (0) I/chromium(26684): [INFO:CONSOLE(596)] "XMLHttpRequest get: ", source: file:///android_asset/www/js/index.js (596) I/chromium(26684): [INFO:CONSOLE(655)] "["before create db put",{},{"response":"","responseText":"","seq_id":1,"id":"1: GET http://356c034d-1ba6-44fe-b599-c7587dbfcb27:d404d28f-91a4-4c32-a23a-d0c224a1a3f6@localhost:5984/todo","_id":"1: GET http://356c034d-1ba6-44fe-b599-c7587dbfcb27:d404d28f-91a4-4c32-a23a-d0c224a1a3f6@localhost:5984/todo","timeoutTimer":4,"statusCode":404,"body":""},null]", source: file:///android_asset/www/js/index.js (655)

What am I missing here?