What is "Debug JS Remotely" doing? - android

Can anyone explain how is it that running the app with "Debug JS Remotely" behaves differently than without it? Currently, my app seems to behave differently between these two modes.
To be specific, when my app is in "Debug JS Remotely", it can fire API requests and get responses successfully. When the app is not in "Debug JS Remotely", it's unable to fire API requests?

The issue you're experiencing might be due to the different Javascript engines involved:
When running on the device, your code will run on the JavascriptCore engine which is bundled with the RN app itself.
When running the remote debugger, your code will run on Chrome's V8 engine, not on the device.
Different environments might behave differently. Take the following example from this article:
Without remote debugging:
new Date("2017-02-12 23:51:31")
.toLocaleDateString('en-US', { day: '2-digit', month: 'short' }) // 02/12/17
With remote debugging:
new Date("2017-02-12 23:51:31")
.toLocaleDateString('en-US', { day: '2-digit', month: 'short' }) // Feb 12
For this reason, I prefer to sometimes use third-party implementations of some native features (like whatwg-fetch instead of using native fetch).
Resources:
React Native Architecture - Javascript VM

Hi as Explained by #Matei above The issue you're experiencing might be due to the different Javascript engines involved
In my case code was running fine in debug mode but as soon i off debug mode screen get stuck
Solution:
So what worked for me was removing all the console.log from the file.
So just remove all the console.log from your code and it will work like a charm.

Related

Chrome devtools blank page when inspecting mobile app

I am developing mobile app(in Ionic4), but I am not able to inspect it and debug it in chrome devtools. When I go to Chrome/inspect the device with running app appears in the list, but when I click on inspect, only blank page opens, it looks like this:
device page
blank inspect page
When i hit Ctrl+Shift+I blank page reopens, and i can look into the console, there are some errors:
Uncaught TypeError: Cannot read property 'appendChild' of null
at installExtraStyleRules (devtools_compatibility.js:1484)
at installBackwardsCompatibility (devtools_compatibility.js:1457)
at devtools_compatibility.js:1504
at devtools_compatibility.js:1506
Uncaught TypeError: Cannot redefine property: keyIdentifier
at Function.defineProperty (<anonymous>)
at installBackwardsCompatibility (devtools_compatibility.js:1381)
at devtools_compatibility.js:1504
at devtools_compatibility.js:1506
[Deprecation] Application Cache was previously restricted to secure origins only from M70 on but now secure origin use is deprecated and will be removed in M82. Please shift your use case over to Service Workers.
Uncaught TypeError: Object.observe is not a function
at WebInspector.Main._createSettings (inspector.js:10380)
at WebInspector.Main._gotPreferences (inspector.js:10372)
at DevToolsAPIImpl.embedderMessageAck (devtools_compatibility.js:43)
at <anonymous>:1:13
Any ideas where is the problem? It happens only on this type of device, on other devices, it works great.
I have a little experience with Ionic. Not a big fan, since this is the start of the bugs you will face. You have to be a professional expert Javascript programmer to understand every bit of the code Ionic uses to compile (to debug and find problems). And even then I find it hard to find some errors too.
My advice is to switch to React Native with the Typescript template. Since Typescript gives you the best linting, help with errors and compiling. I have built multiple apps using Ionic, all far less advanced and beautiful then my React Native work. As well as other programmers to understand you're code, it's better to use Typescript with generics, interfaces, classes and such... If you have any other questions, post them below and I edit this post.

How can I get the layout xml from webDriver.io for android native app?

I'm using WebDriver.io to create tests.
In the Docs getSource doesn't support native apps.
Get source code of the page. This command won’t work in mobile
environments for native apps. If you are running hybrid tests make
sure that you are in the webview before calling this command.
For now, I use "client.source()" link which return the XML but can take up to 20 sec.
How can I get the layout XML from webDriver.io?
You are doing it the right way. Alternatively you can try the WD.js client and check if performance will be better with than the other one, or simply open an issue report on the WebdriverIO Github page.
The reason of why it may take so long:
UI of the app is constantly updating => Appium is hanging for a bit to retrieve it;
Lots of elements on your app page => leads to a big .xml file.

phonegap/cordova app is slower compare to PhoneGap Desktop

Recently I just started to build my app by using phonegap/cordova. At the beginning, I downloaded the Phonegap Desktop and carry out the testing on Phonegap Desktop during development phrase. It is powerful and flexible for testing purpose.
When I am going to complete app, I build the app by using cordova CLI, then install the apk file on my actual device. I found that by using same coding and device, the app is significantly slower than Phonegap Desktop, especially on jquery animate and toggle modal active:
// Simple code for toggle dialog modal to active
$("#modal-launcher, #modal-background, #modal-close").click(function () {
$("#modal-content").css('top', Math.round( $(document).height() - ($("body").innerHeight() / 1.65 ))+'px');
$("#modal-content,#modal-background").toggleClass("active");
});
//Simple code for animate list item
$( '.Class' ).animate({ right:'0px' }, 250);
The speed is same when I just open the app. After I perform some actions to trigger events, I observed the performance is slowing down. For instance I need to wait for few seconds to let dialog prompt out, and the animate become slower as usual. If i restart the app, the performance is become normal again until I repeat same process.
The performance degradation is not just few milliseconds, it is a very significant difference that up to 4 - 6 seconds delay. This would not happen if I switch to Phonegap Desktop, by using same coding and device. This make me have no idea about what is going on, as I thought they share the same framework. I also tried build the app by using phonegap build android and ionic build android, but I get same result as well. Does anyone has similar experience and has any solution for this issue ?
The speed of the device and the version of webview is the important point. On the desktop you have a lot of power and it is okay to make the first steps there, but then switch to slow devices for testing and test the app also with older android versions. The reason is not the compatibility, the reason is, that older androids are slower.
If the app is running well on slower devices, it will work great on new devices.
Cordova itself and javascript are very fast. There are some mistakes which people make, when they start with cordova development and using jQuery/jQuerymobile:
Write clean HTML with a clean structure, try to make the dom simple.
Don't query the dom with jquery over and over again. Instead put your selector in a variable, if you use it several times:
var $selector = $("#myselector);
if ($selector.height() > 100){
// do something
}
Concatenate jQuery operations:
$("#myselector).css("active").text("my new text");
Use find(), next(), parent(), …. If you need to have multiple operations on multiple elements, and the elements are not fare away in the dom, then use find(), next(), parent(), … it is much faster then querying the whole dom.
Don't use jQuery for everything. jQuery is great, but a lot of operations can be done with simple javascript.
Don't use jQuery-plugins for things that can be done easily with javascript.
Make a single-page-html-app and avoid to use multiple html-pages. This is the best way to slow down the speed of your app and to make the development complicate.
Use a custom jQuery download and don't include things you don't need.
Use tap instead of click.

How to run 'spacebrew' in "android mode" from processing?

I am making an andriod app using 'andriod for processing lib" of processing (ie. running android mode in processing 2.0.3 and lauching it on my device).
Spacebrew (http://docs.spacebrew.cc) is a easy to use web socket library for processing , also availabel as javascript.
if i run the spacebrew example codes in andriod mode, the app gets launched in my device but doesnt show up in my spacebrew admin. whereas if i run the same thing in my mac, it shows up correctly. guess the websocket communication is not happening while using "andriod for processing". But this is the easiest way to use web sockets. So can anyone help me figure out on how to make spacebrew work in processing (android mode)
this is for my college project. any suggestions on how to get this running please? thankyou in advance
Thanks for pointing me to Spacebrew, didn't know about that!
I've just tested it from Android Mode and it does work, but there is a tiny quirk you might be missing out: permissions!
Normally, if your app uses extra permissions, the application's manifest allows you to use these. In Processing, that's also possible via Android > Sketch Permissions and in the case of Spacebrew, INTERNET is the permission you need enabled, as you can see below:
I just a did a test myself and it seems to work just fine with the amazon hosted demo:
Note that the Spacebrew Processing library uses the java websocket library, but only sets up a WsClient client. You can if you want use this jar in an Android SDK eclipse project and have your Android app act as a websockets server as well, not just a client (just in case this will become handy to you at some point in the future)

wrapped android-app crashes on resume "no current context"

i got a webapp build via flambe/haxe which is wrapped by phonegap build to get an .ipa and .apk. For now the only remaining error is that the app looses its context if i switch between apps or pressing home-button resulting in the following error on android:
"W/Adreno200-EGL(31381): <qeglDrvAPI_eglSetBlobCacheFuncsQCOM:5575>: EGL_BAD_PARAMETER"
"E/libEGL(31381): eglSetBlobCacheFuncsANDROID resulted in an error: 0x300c"
"E/SurfaceTexture(31381): [unnamed-31381-1] updateTexImage: invalid current EGLContext"
"E/CanvasTexture(31381): unexpected error: updateTexImage return -38"
The last two lines keep repeating (even after several minutes) until i close the app manually which results in the following error-message:
"E/libEGL(21636): call to OpenGL ES API with no current context (logged once per thread)"
Full errorlog can be viewed here: http://goo.gl/UkxwfI (Dropbox)
One thing that keeps bugging me is the following message since all "related" problems got that feature turned ON, but i cant find anything to change that.
"D/webcoreglue(31381): netstack: Memory Cache feature is OFF"
Another thing is with: D/CordovaActivity(31381): CB-3064: The errorUrl is null
As of http://goo.gl/qZWc4F (github) there seems to be a problem on resuming in cordova. (just strg+f "cb-3064")
Took me the whole day to use google on terms like:
EGL_BAD_PARAMETER, qeglDrvAPI_eglSetBlobCacheFuncsQCOM, SurfaceTexture, CanvasTexture, updateTexImage, invalid current EGLContext, eglSetBlobCacheFuncsANDROID, error: 0x300c, OpenGL ES API
but without any good hints or helpful info.
additional information:
tested on Sony Xperia J (ST26i) and android 4.1.2
min android SDK 14
android:hardwareAccelerated="true" (default since sdk 14)
landscape + fullscreen
webview used to display the website coming from flambe/haxe
used build phonegap / phonegap 3.3 (using 2.8 - 3.3 = same)
building it myself via cordova doesnt help (so it should not relate to phonegap build)
cordova.inappbrowser only used to open links in external browser, website running in webview
website only shows a html5-game (nothing fancy, just something like bejeweld)
Maybe there's some easy help by juggling with the Android-Manifest. I really dont want to do native since the webapp is shipped to iOS via Phonegap too.
Update 1
Tried to reproduce the error using native android and playing with different manifest-settings. But it seems like this has something to do with how phonegap/cordova handles the drawing of everything on screen.
Next things to do will involve posting on phonegap-forums and checking out iOS errorlog. Maybe i find something while comparing my results to: iOS app crashes on resuming
Update 2
iOS-Errorlog doesn't help. Exception Type 20 and Exception Code 8badf00d. Stack shows errors with graphics too (like in android). Errorlog see Link in Comment...
"Fixed" by building android and ios myself with cordova. Resuming/Restarting feels a bit bumpy but thats the next thing to fix.
Phonegap build just doesn't like the life cycle of apps.

Categories

Resources