UniversalAvenue / TiCrosswalk

WebView replacement for Titanium Mobile
Other
27 stars 12 forks source link

Errors in example App #7

Closed Pyreweb closed 9 years ago

Pyreweb commented 9 years ago

Hello,

I just copy-pasted parts of the example app (TiCrosswalk/xwtest/app/controllers/index.js) in mine, and it doesn't work well;

var test = require('com.universalavenue.ticrosswalk');
Ti.API.info("module is => " + test);
Ti.API.info("module example() method returns => " + test.example());
Ti.API.info("module exampleProp is => " + test.exampleProp);

On my Jelly Bean emulator, the output is :

[INFO]  module is => [object Object]
[ERROR] TiExceptionHandler: (main) [5649,120556] ----- Titanium Javascript Runtime Error -----
[ERROR] TiExceptionHandler: (main) [1,120557] - In alloy/controllers/activite.js:135,66
[ERROR] TiExceptionHandler: (main) [2,120559] - Message: Uncaught TypeError: Object #<TiCrosswalk> has no method 'example'
[ERROR] TiExceptionHandler: (main) [3,120562] - Source:         Ti.API.info("module example() method returns => " + test.example());
[ERROR] V8Exception: Exception occurred at alloy/controllers/activite.js:135: Uncaught TypeError: Object #<TiCrosswalk> has no method 'example'

If I comment the test.example() call, the output is :

[INFO]  module is => [object Object]
[INFO]  module exampleProp is => undefined

That's the basics; After, I have this, still from the example :

test.exampleProp = "This is a test value";

var webView = test.createWebView({ html: 'http://universalavenue.com' });
$.actwin.add(webView);

Which gave :

[INFO]  module is => [object Object]
[INFO]  module exampleProp is => undefined
[DEBUG] TiCrosswalk: (main) [5650,205088] [VIEW LIFECYCLE EVENT] view, on ui thread: true
[DEBUG] TiCrosswalk: (main) [31,205119] Activity: org.appcelerator.titanium.TiActivity@411c9258, context:com.pyreweb.exostim.ExostimApplication@40ceb010
[INFO]  LibraryLoader: Expected native library version number "",actual native library version number ""
[INFO]  chromium: [INFO:library_loader_hooks.cc(104)] Chromium logging enabled: level = 0, default verbosity = 0
[DEBUG] dalvikvm: GREF has increased to 301
[INFO]  BrowserStartupController: Initializing chromium process, singleProcess=true
[INFO]  ResourceExtractor: Extracting resource icudtl.dat
[INFO]  ResourceExtractor: Extracting resource xwalk.pak
[ERROR] chromium: [ERROR:address_tracker_linux.cc(154)] Could not bind NETLINK socket: Address already in use
[ERROR] dalvikvm: Could not find class 'android.bluetooth.BluetoothManager', referenced from method org.chromium.media.AudioManagerAndroid.hasBluetoothHeadset
[WARN]  dalvikvm: VFY: unable to resolve check-cast 55 (Landroid/bluetooth/BluetoothManager;) in Lorg/chromium/media/AudioManagerAndroid;
[DEBUG] dalvikvm: VFY: replacing opcode 0x1f at 0x001d
[WARN]  AudioManagerAndroid: Requires BLUETOOTH permission
[WARN]  chromium: [WARNING:proxy_service.cc(909)] PAC support disabled because there is no system implementation
[DEBUG] dalvikvm: GREF has increased to 401
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/presentation_api.js
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/launch_screen_api.js
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/contacts_api.js
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/device_capabilities_api.js
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/messaging_api.js
[DEBUG] TiCrosswalk: (main) [3055,208174] WebView created with props: {"visible":true,"enabled":true,"backgroundRepeat":false,"html":"http:\/\/universalavenue.com"}
[DEBUG] TiCrosswalk: (main) [1,208175] Loading html string
[DEBUG] D/        : HostConnection::get() New Host Connection established 0x2a5c8b40, tid 1150
[INFO]  chromium: [INFO:xwalk_extension_renderer_controller.cc(47)] EXTENSION PROCESS DISABLED.
[ERROR] EGL_emulation: eglQuerySurface 30be  EGL_BAD_ATTRIBUTE
[ERROR] chromium: [ERROR:buffer_manager.cc(313)] [.BrowserCompositor-0x2a594038]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command
[DEBUG] WebViewResourceClient: (main) [2685,210860] WebView finished loading url: about:blank

And the webview is blank, and black.

I installed the module via Gittio only, it may had an impact ?

jonatansberg commented 9 years ago

Hi there, I think that test app is fairly outdated.. To use the WebView in an Alloy project:

<WebView id="webView" platform="ios" />
<WebView id="webView" platform="android" module="com.universalavenue.ticrosswalk" />

Otherwise just call the createWebView([props]) method on the module (when on Android) and use the evalAsync(code, [callback]) method to access the WebView JS context.

On iOS the module simply extends the existing WebView, meaning you can use the same APIs as on Android.

Cheers!

jonatansberg commented 9 years ago

I've added a simple usage section to the README now. If you'd like to fix up the test app as well, feel free to do so! I love pull requests. :smile:

Pyreweb commented 9 years ago

Oh, that's better and far easier :) I may look into updating the example app (if I can make mine work, priorities ;)), it'll help !

Still, not working directly, that'll be too easy

[DEBUG] TiCrosswalk: (main) [1543,50050] [VIEW LIFECYCLE EVENT] view, on ui thread: true
[DEBUG] TiCrosswalk: (main) [5,50055] Activity: org.appcelerator.titanium.TiActivity@4116cdc8, context:com.pyreweb.exostim.ExostimApplication@40cea148
[INFO]  dalvikvm: Jit: resizing JitTable from 4096 to 8192
[INFO]  LibraryLoader: Expected native library version number "",actual native library version number ""
[INFO]  chromium: [INFO:library_loader_hooks.cc(104)] Chromium logging enabled: level = 0, default verbosity = 0
[DEBUG] dalvikvm: GREF has increased to 301
[INFO]  BrowserStartupController: Initializing chromium process, singleProcess=true
[INFO]  ResourceExtractor: Extracting resource icudtl.dat
[INFO]  ResourceExtractor: Extracting resource xwalk.pak
[ERROR] dalvikvm: Could not find class 'android.bluetooth.BluetoothManager', referenced from method org.chromium.media.AudioManagerAndroid.hasBluetoothHeadset
[WARN]  dalvikvm: VFY: unable to resolve check-cast 55 (Landroid/bluetooth/BluetoothManager;) in Lorg/chromium/media/AudioManagerAndroid;
[DEBUG] dalvikvm: VFY: replacing opcode 0x1f at 0x001d
[WARN]  AudioManagerAndroid: Requires BLUETOOTH permission
[WARN]  chromium: [WARNING:proxy_service.cc(909)] PAC support disabled because there is no system implementation
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/presentation_api.js
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/launch_screen_api.js
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/contacts_api.js
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/device_capabilities_api.js
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/messaging_api.js
[DEBUG] TiCrosswalk: (main) [4030,54085] WebView created with props: {"id":"viewAct","enabled":true,"visible":true,"backgroundColor":"#333","backgroundRepeat":false}
[DEBUG] Window: Checkpoint: postWindowCreated()
[DEBUG] dalvikvm: --- called into dvmAbstractMethodStub
[ERROR] TiBaseActivity: (main) [107,54192] Error dispatching lifecycle event: abstract method not implemented
[ERROR] TiBaseActivity: java.lang.AbstractMethodError: abstract method not implemented
[ERROR] TiBaseActivity:     at com.universalavenue.ticrosswalk.WebView.onCreate(WebView.java)
[ERROR] TiBaseActivity:     at org.appcelerator.titanium.TiLifecycle.fireLifecycleEvent(TiLifecycle.java:160)
[ERROR] TiBaseActivity:     at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:563)
[ERROR] TiBaseActivity:     at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18)
[ERROR] TiBaseActivity:     at android.app.Activity.performCreate(Activity.java:5104)
[ERROR] TiBaseActivity:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
[ERROR] TiBaseActivity:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
[ERROR] TiBaseActivity:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
[ERROR] TiBaseActivity:     at android.app.ActivityThread.access$600(ActivityThread.java:141)
[ERROR] TiBaseActivity:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
[ERROR] TiBaseActivity:     at android.os.Handler.dispatchMessage(Handler.java:99)
[ERROR] TiBaseActivity:     at android.os.Looper.loop(Looper.java:137)
[ERROR] TiBaseActivity:     at android.app.ActivityThread.main(ActivityThread.java:5041)
[ERROR] TiBaseActivity:     at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] TiBaseActivity:     at java.lang.reflect.Method.invoke(Method.java:511)
[ERROR] TiBaseActivity:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
[ERROR] TiBaseActivity:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
[ERROR] TiBaseActivity:     at dalvik.system.NativeStart.main(Native Method)
[INFO]  TiCrosswalk: (main) [31,54223] onStart
[INFO]  TiCrosswalk: (main) [40,54263] onResume
[INFO]  TiCrosswalk: (main) [0,54263] onResume view found
[WARN]  EGL_emulation: eglSurfaceAttrib not implemented
[DEBUG] D/        : HostConnection::get() New Host Connection established 0x2a4fc2c8, tid 1109
[ERROR] EGL_emulation: eglQuerySurface 30be  EGL_BAD_ATTRIBUTE
[ERROR] chromium: [ERROR:buffer_manager.cc(313)] [.BrowserCompositor-0x2a4fb7e0]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command
[WARN]  EGL_emulation: eglSurfaceAttrib not implemented
[DEBUG] TiCrosswalk: (main) [1968,56231] Loading new url: app://activites/activite.html
[INFO]  chromium: [INFO:xwalk_extension_renderer_controller.cc(47)] EXTENSION PROCESS DISABLED.
[DEBUG] WebViewResourceClient: (main) [3185,59416] WebView finished loading url: app://activites/activite.html

And still a blank and black screen.

And those in particular bugs me :

[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/presentation_api.js
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/launch_screen_api.js
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/contacts_api.js
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/device_capabilities_api.js
[WARN]  BuiltinXWalkExtension: Failed to read JS API file: jsapi/messaging_api.js

That's normal ?

jonatansberg commented 9 years ago

The BuiltinXWalkExtension warnings are "normal", or at least I get them too. The real issue seems to be that onCreate lifecycle method is not implemented, a bit further up in the log. What's even more interesting is that I am not getting that error.

Have you tried using the module on an actual device? Implementing a dummy onCreate method (like onStop) might also be a potential fix.

jonatansberg commented 9 years ago

@Pyreweb Here's a custom build with a dummy onCreate method: http://we.tl/ofzy4SofiB

Pyreweb commented 9 years ago

No, I'm using a simulator/emulator actually. Configuration is Android 4.2.2 (Google API's image on ARM), API Level 17.

I'll look on a real device whenever I can.

jonatansberg commented 9 years ago

Ok. Feel free to try the bulid I linked to above. It might fix things for you on the emulator.

Pyreweb commented 9 years ago

Your build indeed fixed the lifecycle bug.

The original issue is now closed ! :smile: