NWJS app crashing because of website console errors - javascript

I've a NW.JS desktop app keeps crashing because of webpage errors.
I'm trying to open this webpage inside my app - URL
As soon as the pages get loaded my app starts to crash with the following error:
[3491:775:0210/215448.347299:FATAL:native_extension_bindings_system.cc(214)] Check failed: schema. arcAppsPrivate
0 nwjs Framework 0x000000011243a239 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 14936185
1 nwjs Framework 0x000000011239a8f3 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 14282547
2 nwjs Framework 0x00000001123ad73f v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 14359935
3 nwjs Framework 0x00000001123ae5ee v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 14363694
4 nwjs Framework 0x0000000111ad1838 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5070456
5 nwjs Framework 0x0000000111a9900a v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 4838986
6 nwjs Framework 0x0000000111a98f7d v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 4838845
7 nwjs Framework 0x0000000111ad4de8 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5084200
8 nwjs Framework 0x0000000111ad48b3 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5082867
9 nwjs Framework 0x0000000111ad4253 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5081235
10 nwjs Framework 0x0000000111ad447f v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5081791
11 nwjs Framework 0x0000000110f02f73 v8::internal::FixedArray::SetAndGrow(v8::internal::Isolate*, v8::internal::Handle<v8::internal::FixedArray>, int, v8::internal::Handle<v8::internal::Object>) + 1763
12 nwjs Framework 0x0000000110f02321 v8::internal::Object::GetProperty(v8::internal::LookupIterator*, bool) + 3041
13 nwjs Framework 0x0000000110f01814 v8::internal::Object::GetProperty(v8::internal::LookupIterator*, bool) + 212
14 nwjs Framework 0x0000000111048bf5 v8::internal::Runtime::GetObjectProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, bool*) + 181
15 nwjs Framework 0x000000011104f103 v8::internal::Runtime::DefineObjectOwnProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::StoreOrigin, v8::Maybe<v8::internal::ShouldThrow>) + 13571
16 ??? 0x0000003707f0a8f8 0x0 + 236356413688
17 ??? 0x0000003707fa17b6 0x0 + 236357031862
18 ??? 0x0000003707e8c862 0x0 + 236355897442
Task trace:
0 nwjs Framework 0x0000000115920992 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 70406098
1 nwjs Framework 0x00000001125fe106 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 16787270
IPC message handler context: 0x95373B38
Crash keys:
"discardable-memory-free" = "2715648"
"discardable-memory-allocated" = "4194304"
"view-count" = "3"
"extension-1" = "jhedmmohalmhagooekjmhcjkphpnfmfa"
"num-extensions" = "1"
"blink_scheduler_async_stack" = "0x115920992 0x1125FE106"
"v8_code_space_firstpage_address" = "0x3700000000"
"v8_map_space_firstpage_address" = "0x3708180000"
"v8_ro_space_firstpage_address" = "0x3708000000"
"v8_isolate_address" = "0x7ff2f8c44000"
"variations" = "f475deb0-f475deb0,313957be-3ef44cd2,7e184ca7-2ec1a7e,60c843ad-3f4a17df,3fa8d059-3fa8d059,3c98d047-3f4a17df,8950ab95-3f4a17df,6cbcf5b7-3f4a17df,4701a278-3f4a17df,4749874c-a300a3e6,65570806-377be55a,6aa15a86-9d8c1aae,8e3b682d-3f4a17df,722b8030-3f4a17df,3042ad4b-ad2fa222,e4a357e9-3f4a17df,3fd33f16-fa281276,5252c71-3f4a17df,e79de56c-dee0823,8bccc03b-3f4a17df,178e8b37-3f4a17df,facdb7bf-3f4a17df,69d4ebd5-3f4a17df,9e5c75f1-30e1b12b,255dfea8-cf12f279,a083757a-d6a08b38,e4cbd6c7-3f4a17df,f7a3ec9-bd336006,3487aa71-84708353,23a898eb-fc93cf74,d3566fbd-c6f74b94,4ea303a6-3f4a17df,7048821f-7b0f7072,ef4764d7-c9f4d4ef,931c5f72-3f4a17df,ade3efeb-e1cc0f14,32d6b1fe-3f4a17df,ae82076d-3f4a17df,17b84626-3f4a17df,8d7344de-3f4a17df,1bb6a450-3f4a17df,3e7d7783-f38a9353,90a7075b-725c8fbe,1d606bb5-8d14c5d8,a0da97d6-3f4a17df,3b96a1d-3f4a17df,248e3a0-3f4a17df,dba92675-f23d1dea,5306c29b-9cbf73ff,f8a7f5e4-d6a08b38,e87da360-3f4a17df,39ec51c3-572726d7,77e44b8e-3f4a17df,6c5f69af-3f4a17df,bef5c006-3f4a17df,fc7e4d22-3f4a17df,7638c831-857014ec,a112f012-3f4a17df,6e08fc3e-3f4a17df,8470b833-3f4a17df,6be2e990-3f4a17df,47d92407-5b5edf5b,4b9a5bc0-efbbc50a,49a20295-49a20295,f2cb61f-3f4a17df,8c8d8faf-3f4a17df,727723f1-40193c20,b012722b-3f4a17df,d8692482-fe3984ae,29c62d4-3f4a17df,7760b5b2-3f4a17df,ad4acdda-3f4a17df,234de0a0-ace4e138,b1ceb06f-3f4a17df,ca5a2953-ff983c32,4e3ec83a-e4938e2c,7f655da7-3f4a17df,248c3fbd-3f4a17df,6cb5e962-3f4a17df,bf4029fe-1776d9e,6a5f15b-3f4a17df,61a655b5-3f4a17df,54410569-3f4a17df,6aa685f2-dcaf2061,f48c01d3-6eb2bd2b,89a16501-3f4a17df,"
"num-experiments" = "86"
"switch-21" = "--user-data-dir=/path/temp/userdatadir/profile2"
"switch-20" = "--user-data-dir=/path/temp/userdatadir/profile2"
"switch-19" = "--disable-gpu"
"switch-18" = "--field-trial-handle=1718379636,962445429152936292,7087525159415"
"switch-17" = "--shared-files"
"switch-16" = "--launch-time-ticks=8302334130"
"switch-15" = "--renderer-client-id=6"
"switch-14" = "--enable-main-frame-before-activation"
"switch-13" = "--enable-gpu-memory-buffer-compositor-resources"
"switch-12" = "--enable-zero-copy"
"switch-11" = "--num-raster-threads=4"
"switch-10" = "--lang=en-GB"
"switch-9" = "--disable-gpu-compositing"
"switch-8" = "--no-zygote"
"switch-7" = "--file-url-path-alias=/gen=/path/software/nwjs-sdk-"
"switch-6" = "--no-sandbox"
"switch-5" = "--display-capture-permissions-policy-allowed"
"switch-4" = "--extension-process"
"switch-3" = "--nwjs"
"switch-2" = "--nwapp-path=/path/projects/soft-v2/nw"
"switch-1" = "--user-data-dir=/path/temp/userdatadir/profile2"
"num-switches" = "24"
"osarch" = "x86_64"
"pid" = "3491"
"ptype" = "renderer"
[0210/215448.351355:WARNING:process_memory_mac.cc(93)] mach_vm_read(0x7ffeebe70000, 0x2000): (os/kern) invalid address (1)
[3486:12803:0210/215448.434605:ERROR:ssl_client_socket_impl.cc(995)] handshake failed; returned -1, SSL error code 1, net_error -200
[3486:18691:0210/215448.806969:WARNING:sqlite_persistent_store_backend_base.cc(171)] Failed to post task from FlushAndNotifyInBackground#net/extras/sqlite/sqlite_persistent_store_backend_base.cc:219 to client_task_runner_.
[3486:18691:0210/215448.807044:WARNING:sqlite_persistent_store_backend_base.cc(171)] Failed to post task from FlushAndNotifyInBackground#net/extras/sqlite/sqlite_persistent_store_backend_base.cc:219 to client_task_runner_.
[3475:775:0210/215448.857362:WARNING:pref_notifier_impl.cc(40)] Pref observer for media_router.cast_allow_all_ips found at shutdown.
There's a similar issue already open - URL
I tried upgrading/downgrading NWJS version.
Tried passing the
flags suggested in one of the comments of the github issue
Tried
adding try catch to window open like below:
try {
nw.Window.open(url);
}
catch(err) {
log.info("Got error")
}
Tried different OS (Mac & Windows)
It crashes with both 32 Bit NWJS and 64 Bit. Tried both of them.
But nothing is working.
However, another page link of the same website is working, which does not have console errors and much content. URL
Need help in understanding the problem and fixing it.
Also, I'm surprised as well, since a webpage can cause the NWJS desktop app to crash.

I could be wrong, but I think the feature you're looking for is:
nw.Shell.openExternal('https://seller.flipkart.com/sell-online');
That page just looks like a normal website, not a desktop app that would need access to Node.js. So you can just use nw.Shell.openExternal to open the page in the user's default browser. For security reasons, it's best to avoid using node-remote unless you are running a local webserver and pointing it to "http://localhost:8000" (or whatever port).

Related

How do I read the local storage of my Safari Web Extension using Selenium in Python?

With the Firefox WebDriver I can read the local storage of my extension like so:
extension_path = "/path/to/my/extension"
info = {
"extension_id": f"foobar",
"uuid": uuid.uuid4(),
}
base_url = f"moz-extension://{info['uuid']}/"
opts = FirefoxOptions()
opts.set_preference('extensions.webextensions.uuids', '{"%s": "%s"}' % (
info["extension_id"], info["uuid"]))
driver = webdriver.Firefox(options=opts)
driver.install_addon(extension_path, temporary=True)
driver.get(f"{base_url}_generated_background_page.html")
results = self.driver.execute_async_script((
"let done = arguments[arguments.length - 1],"
" store_name = arguments[0];"
"browser.storage.local.get([store_name], function (res) {"
" done(res[store_name]);"
"});"
), "foo")
How can I do the same with the Safari WebDriver on macOS? I've ported the extension using xcrun safari-web-extension-converter /path/to/my/extension and built and manually tested that it works in Safari. In Safari I can go to Develop -> Web Extension Background Pages -> <my web extension> to find the id of the extension and see that a generated background page is located at safari-web-extension://<id>/_generated_background_page.html
But running the following results in Selenium freezing at driver.get(f"{base_url}_generated_background_page.html")
base_url = f"safari-web-extension://<id>/"
driver = webdriver.Safari()
driver.get(f"{base_url}_generated_background_page.html")
results = self.driver.execute_async_script((
"let done = arguments[arguments.length - 1],"
" store_name = arguments[0];"
"browser.storage.local.get([store_name], function (res) {"
" done(res[store_name]);"
"});"
), "foo")
What can I do?
Update Feb 8th 2023
I have also tried an approach using browser.runtime.sendMessage where in Python Selenium I do this:
results = self.driver.execute_async_script((
"let done = arguments[arguments.length - 1],"
" store_name = arguments[0];"
" browser.runtime.sendMessage('com.oskar.foo.Extension (Apple Team ID)', {}, function (res) {"
" done(res[store_name]);"
" });"
), "foo")
and add the following to background.js in the extension:
browser.runtime.onMessageExternal.addListener(function (
request,
sender,
sendResponse
) {
browser.storage.local.get("foo").then((j) => {
sendResponse(j);
});
return true;
});
and this to the manifest.json
"externally_connectable": {
"ids": ["*"],
"matches": ["https://example.org/*"]
}
This way I actually get a value from the extension when running the test. But instead of reading the storage of the extension from the Safari instance started by Selenium, it reads the storage of the extension from the "real" safari instance.
I'm not very knowledgeable on the subject. However, such requests; It may be that it needs to provide duplex communication, including outgoing request and callback, and in this case, it may hang due to network needs.
In the link below, the transaction was made by polling with wait. I think this kind of approach can solve the problem. Also mentioned here is a bug, care it.
https://stackoverflow.com/a/28066902/914284

How can I stop IE 11/Win7 from removing ".exe" from downloade files?

I have an application which I have created an installer for. I have signed the application with a certificate. With every browser/windows combination I have tried downloading the installer works fine, except Windows 7 IE 11.
This combination strips the .exe off of the file. If I add the .exe back, the installer works fine. The file resides on the web server and I cause the download using the following JS;
function processDownload(inInstalLink, ApplicationName)
{
if (confirm("Download "+ ApplicationName + " application?"))
{
var intRandom = Math.floor((Math.random() * 10000) + 1);
window.location = inInstalLink + "?tempID=" + intRandom; //Launch alternative, typically app download.
}
}
I call the javascript above as follows;
processDownload("MyInstaller.exe", "My Fun Application")
I have read about content disposition tags, but am at a loss on how to implement them here, and not sure if they would solve the problem. Any guidance is appreciated.
This seems to be a common problem in Windows 7 IE 11 with exe downloads without a content disposition.
One solution that others have tried and had success with is appending ‘.exe’ to the url.
window.location = inInstalLink + "?tempID=" + intRandom + ".exe"
With dealing with IE compatibility, sometimes solutions aren’t as intuitive or logical as we would like them to be.

MFF 8.0 invokeProcedure ReferenceError

I'm migrating MobileFirst Web(Javascript) application developed in MFP7.1 to MFF8.0. When call a Javascript adapter, the following error happens. Does anyone give an advise how to fix the problem?
Error Message:
ibmmfpf.js:2040 Uncaught ReferenceError: extendWithDefaultOptions is not defined
at __WLClient.invokeProcedure (ibmmfpf.js:2040)
Code:
var proc = function(procedure, parameters) {
return WL.Client.invokeProcedure({
adapter: ‘XXXXXXX’,
procedure: procedure,
parameters : (parameters || [])
}, {
timeout: 60000
});
};
var standardHandler = function(res) {
if (typeof res.responseJSON === 'object' && res.responseJSON.code > 0) {
return $.Deferred().reject(res).promise();
}
return $.Deferred().resolve(res).promise();
};
//// invoking proc
return proc(‘getYYYYY’).then(standardHandler);
Some of the APIs from MFP 7.1 have been changed in MFP 8.0.Use Migration Cookbook tool.This tool helps you by identifying areas in your codebase that you will need to inspect and alter, such as APIs that are deprecated, no longer supported, or modified.
For more details about migration IBM MobileFirst Platform Foundation 6.3 - 7.1, to IBM Mobile Foundation 8.0. see below links
Migrating apps from earlier releases
Migrating apps and adapters to MobileFirst Foundation 8.0
Developing for Cordova application

0x8badf00d in React native iOS

I am developing a React Native (0.45.0) application and once in a couple of hours my application crashes (or rather gets killed by watchdog) with 0x8badf00d. I understand why watchdog kills the application; the main thread takes longer than 20 seconds to respond to an event. But I have no idea how to debug this in React Native. Everything is in Javascript and in promises so I am assuming that the network execution that I am doing is already asynchronous.
The application seems to be only crashing while it's in the background. However, the crash reports role states Foreground. We are using background fetch and background geolocation which both do a network request. I have measured the time from event trigger to finish and it does not take longer than one second in total.
I read that the most common problem for this error to happen is a network request on the main threat. Could it be that it tries to load the js bundle synchronously and hangs? How can I debug this problem when all my code is in Javascript?
Thank you very much in advance.
Incident Identifier: 36E63A5F-7C40-40C0-9914-2C9EAE494C11
Beta Identifier: 3C432B54-1947-470E-A387-6566A494E145
Hardware Model: iPhone7,2
Process: [993]
Path: /private/var/containers/Bundle/Application/70B3363C-32E9-4D26-B6C6-DB51304D46C7/.app/
Identifier: org.reactjs.native.example.Test3
Version: 20 (1.4)
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: org.reactjs.native.example.Test3 [703]
Date/Time: 2017-07-17 21:31:33.1931 -0400
Launch Time: 2017-07-17 19:18:30.9574 -0400
OS Version: iPhone OS 10.3.2 (14F89)
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace <0xF>, Code 0x8badf00d
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib
0x0000000182a07224 0x182a06000 + 4644
1 libsystem_kernel.dylib
0x0000000182a0709c 0x182a06000 + 4252
2 CoreFoundation
0x00000001839d8e90 0x1838fe000 + 896656
3 CoreFoundation
0x00000001839d6ae4 0x1838fe000 + 887524
4 CoreFoundation
0x0000000183906da4 0x1838fe000 + 36260
5 GraphicsServices
0x0000000185370074 0x185364000 + 49268
6 UIKit
0x0000000189bc1058 0x189b4c000 + 479320
7
0x00000001000bfa08 0x1000b8000 + 31240
8 libdyld.dylib
0x000000018291559c 0x182911000 + 17820
Update, symbolized part of the crash log:
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000182faf224 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x0000000182faf09c mach_msg + 72
2 CoreFoundation 0x0000000183f80e90 __CFRunLoopServiceMachPort + 192
3 CoreFoundation 0x0000000183f7eae4 __CFRunLoopRun + 1060
4 CoreFoundation 0x0000000183eaeda4 CFRunLoopRunSpecific + 424
5 GraphicsServices 0x0000000185918074 GSEventRunModal + 100
6 UIKit 0x000000018a169058 UIApplicationMain + 208
7 0x0000000100063294 0x10005c000 + 29332
8 libdyld.dylib 0x0000000182ebd59c start + 4

Why is WInJS included automatically when targeting Windows 8 in Cordova?

We're developing an app using AngularJS, and when we're targeting Windows 8 I noticed that the generated Visual Studio project included WinJS as a reference. Since we're not using WinJS I simply removed the reference from the project.
Then I noticed that removing WinJS caused benign script load errors in the console when running the app. Further investigation showed that cordova.js automatically checks for WinJS, and if not included tries to include it (!). Here's the relevant code:
var onWinJSReady = function () {
var app = WinJS.Application;
var checkpointHandler = function checkpointHandler() {
cordova.fireDocumentEvent('pause',null,true);
};
var resumingHandler = function resumingHandler() {
cordova.fireDocumentEvent('resume',null,true);
};
app.addEventListener("checkpoint", checkpointHandler);
Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);
app.start();
};
if (!window.WinJS) {
var scriptElem = document.createElement("script");
if (navigator.appVersion.indexOf("Windows Phone 8.1;") !== -1) {
// windows phone 8.1 + Mobile IE 11
scriptElem.src = "//Microsoft.Phone.WinJS.2.1/js/base.js";
} else if (navigator.appVersion.indexOf("MSAppHost/2.0;") !== -1) {
// windows 8.1 + IE 11
scriptElem.src = "//Microsoft.WinJS.2.0/js/base.js";
} else {
// windows 8.0 + IE 10
scriptElem.src = "//Microsoft.WinJS.1.0/js/base.js";
}
scriptElem.addEventListener("load", onWinJSReady);
document.head.appendChild(scriptElem);
}
else {
onWinJSReady();
}
I guess my main question is, should I just leave the WinJS reference "as is" and let Cordova load and initialize WinJS?
Could it potentially conflict with AngularJS or reduce the performance of the app in any way?
(I guess var app = WinJS.Application and app.start() in onWinJSReady makes me a bit worried).
Since the app seems to work fine without the WinJS script files, why is cordova.js so insistent on trying to include it?
cordova (and some cordova plugins, particularly the FileSystem plugin) use some features of WinJS, such as Promises and Ajax calls. We ended up forking cordova.js and stripping out all the WinJS stuff... makes the app load a lot faster!

Categories

Resources