LiquidPlayer / LiquidCore

Node.js virtual machine for Android and iOS
MIT License
1.01k stars 127 forks source link

Crash on ArrayBuffer::GetContents() when using webtorrent on iOS #82

Closed liurenqiu520 closed 5 years ago

liurenqiu520 commented 5 years ago

?

liurenqiu520 commented 5 years ago

webtorrent crash image

ericwlange commented 5 years ago

I closed the issue because there was no information -- only a 4 word heading.

Can you provide steps to reproduce this?

liurenqiu520 commented 5 years ago
let url = Bundle.main.url(forResource: "webtorrent", withExtension: "js")
let service = LCMicroService.init(url: url!, delegate: self)
service?.start()

just run this crashed. i am use webpack to pack webtorrent.js, when run this script in my mac is ok, but in ios, just crashed.

ericwlange commented 5 years ago

I was able to reproduce this and can confirm that this is a bug. It should be a relatively simple fix (I think) that I will slate into the 0.6.0 release.

Notes below are more for me than anyone else:

Typed array constructors need to be polyfilled to explicitly (rather than implicitly) create an ArrayBuffer. For example, Int8Array has 5 constructors:

new Int8Array(); // new in ES2017
new Int8Array(length);
new Int8Array(typedArray);
new Int8Array(object);
new Int8Array(buffer [, byteOffset [, length]]);

All of them should work in JavaScript, however the V8 C++ API won't work on the first four, because the underlying ArrayBuffer wasn't created from V82JSC (but from JavaScriptCore directly), so the extra info required by V82JSC is not attached to the object.

This will be fixed in V82JSC by amending the typedarray.js polyfill.

liurenqiu520 commented 5 years ago

thx for reply, waiting for fix it

ericwlange commented 5 years ago

In your local LiquidCore build, replace the file LiquidCoreiOS/LiquidCore/node-8.9.3/V82JSC/polyfill/typedarray.js with the following contents and try again:

/*
 * Copyright (c) 2018 Eric Lange
 *
 * Distributed under the MIT License.  See LICENSE.md at
 * https://github.com/LiquidPlayer/LiquidCore for terms and conditions.
 */

/* In JavaScriptCore, a typed array that is constructed with an ArrayBuffer with non-integer
 * offset and/or length arguments will be treated as a zero-length array.  V8 takes the size
 * of the underlying ArrayBuffer.  We simulate that here.
 */

(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
    typeof define === 'function' && define.amd ? define(factory) :
    (factory());
}(this, (function () { 'use strict';
  const handler = {
    construct(target, args, newTarget) {
      if (typeof args[0] === 'object' &&
        args[0] instanceof ArrayBuffer &&
        args.length >= 3 &&
        (args[1] === undefined || args[1] === null) &&
        (args[2] === undefined || args[2] === null)) {

        return Reflect.construct(target, [args[0], 0, args[0].byteLength], newTarget);
      } else if (typeof args[0] === 'number') {
        return Reflect.construct(target, [new ArrayBuffer(args[0] * Reflect.get(target, 'BYTES_PER_ELEMENT'))], newTarget);
      } else {
        return Reflect.construct(target, args, newTarget);
      }
    }
  };
  Uint8Array = new Proxy(Uint8Array, handler);
  Uint16Array = new Proxy(Uint16Array, handler);
  Uint32Array = new Proxy(Uint32Array, handler);
  Uint8ClampedArray = new Proxy(Uint8ClampedArray, handler);
  Int8Array = new Proxy(Int8Array, handler);
  Int16Array = new Proxy(Int16Array, handler);
  Int32Array = new Proxy(Int32Array, handler);
  Float32Array = new Proxy(Float32Array, handler);
  Float64Array = new Proxy(Float64Array, handler);
})));

I was able to get webtorrent to load properly with that change.

liurenqiu520 commented 5 years ago

i did replace this file and rebuild framework, but still crash, is there anything else need to change?

ericwlange commented 5 years ago

Is it crashing in the same place?

liurenqiu520 commented 5 years ago

yes, i am used carthage rebuild 0.5.1

ericwlange commented 5 years ago

It should have fixed the issue. It sounds like the file didn't get updated or didn't get recompiled properly. If you are using Carthage, I think you would replace it in Carthage/Checkouts/LiquidCore/LiquidCoreiOS/LiquidCore/node-8.9.3/V82JSC/polyfill/typedarray.js.

Is that what you did? You should make sure the file isn't somehow getting overwritten by Carthage.

liurenqiu520 commented 5 years ago

yes, i just do it like you say, when build complete, the typedarray.js dos not overwritten, the polyfill.c was rebuild by new typedarray.js image

ericwlange commented 5 years ago

This is a carthage issue. It always wants to build from a tag in a repo. Since your Cartfile probably has git "git@github.com:LiquidPlayer/LiquidCore.git" ~> 0.5.1, it is always re-checking out 0.5.1 and overwriting your change to typedarray.js.

I'm not quite sure how to get it to stop doing that. I suggest you open the LiquidCore project in XCode, make the change, and then build from XCode, instead of calling carthage build. You would then need to link to that framework instead of the carthage generated one.

I hate carthage. I am moving to cocoapods in version 0.6.0.

liurenqiu520 commented 5 years ago

still ..... image my js file webtorrent.js.zip

ericwlange commented 5 years ago

I'm not sure why you can't get that file to overwrite. You will just have to wait for 0.6.0:

I was able to get webtorrent to sort-of work, but it exposed other bugs that I need to fix, so this is still not ready for use. I will continue to try to fix these issues for 0.6.0. Below are my notes for further bugs:

First, noperfctr_macros.py is not being used to filter out unused macros like it is supposed to. It is in generate_node_javascript_input.txt, but for some reason doesn't seem to be used. This may only be a bug in the cocoapods spec and not exist in carthage, but I am not sure yet. I was able to work around it by adding the following lines to the top of my script:

global.DTRACE_HTTP_CLIENT_REQUEST = function() {}
global.LTTNG_HTTP_CLIENT_REQUEST = function() {}
global.COUNTER_HTTP_CLIENT_REQUEST = function() {}
global.COUNTER_HTTP_CLIENT_RESPONSE = function() {}

This made it so that I was able to successfully download a test torrent. However, the process spews out a few errors along the way and will eventually crash:

(1) I get a number of these:

FIXME! Isolate::ReportExternalAllocationLimitReached()
FIXME! Isolate::ReportExternalAllocationLimitReached()
FIXME! Isolate::ReportExternalAllocationLimitReached()
FIXME! Isolate::ReportExternalAllocationLimitReached()
FIXME! Isolate::ReportExternalAllocationLimitReached()
FIXME! Isolate::ReportExternalAllocationLimitReached()

They don't seem to cause a problem, and this is just an unimplemented function in V82JSC, but I need to check to see if the breached allocation limit is supposed to happen or not.

(2) An exception is getting thrown during some periodic (approximately once a second) callback:

caramlview[58276:106916699] There is an unhandled exception!
caramlview[58276:106916699] Error: TypeError: null is not an object (evaluating 'dict.msg_type')
caramlview[58276:106916699] Stack: onMessage@liquid.bundle.js:32922:21
_onExtended@liquid.bundle.js:16178:37
_write@liquid.bundle.js:16206:21
doWrite@liquid.bundle.js:4816:72
writeOrBuffer@liquid.bundle.js:4805:14
write@liquid.bundle.js:4730:26
ondata@_stream_readable.js:639:25
emitOne@events.js:116:17
emit@events.js:211:14
addChunk@_stream_readable.js:263:16
readableAddChunk@_stream_readable.js:250:19
onread@net.js:594:24

Again, this doesn't seem fatal, but probably should not happen.

(3) Much later, long after the file is downloaded, the process crashes with the following trace:

/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/caramlview[58276]: /Users/eric/workspace/LiquidPlayer/LiquidCore/deps/node-8.9.3/src/timer_wrap.cc:97:static void node::(anonymous namespace)::TimerWrap::Start(const FunctionCallbackInfo<v8::Value> &): Assertion `HandleWrap::IsAlive(wrap)' failed.
 1: node::Abort() [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
 2: node::Assert(char const* const (*) [4]) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
 3: node::(anonymous namespace)::TimerWrap::Start(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
 4: OpaqueJSValue const* callAsCallback<OpaqueJSValue const*>(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
 5: TemplateImpl::callAsFunctionCallback(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
 6: JSC::JSCallbackObject<JSC::JSDestructibleObject>::call(JSC::ExecState*) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore]
 7: JSC::handleHostCall(JSC::ExecState*, JSC::JSValue, JSC::CallLinkInfo*) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore]
 8: operationLinkCall [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore]
 9: 0x30a588400127
10: 0x30a54841f813
11: 0x30a5486215fb
12: 0x30a54860cdcd
13: 0x30a5484f90cb
14: vmEntryToJavaScript [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore]
15: JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore]
16: JSC::profiledCall(JSC::ExecState*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore]
17: JSObjectCallAsFunction [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore]
18: v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
19: node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
20: node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
21: node::AsyncWrap::MakeCallback(unsigned int, int, v8::Local<v8::Value>*) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
22: node::(anonymous namespace)::TimerWrap::OnTimeout(uv_timer_s*) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
23: uv__run_timers [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
24: uv_run [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
25: NodeInstance::StartInstance(void*, node::IsolateData*, int, char const* const*, int, char const* const*) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
26: NodeInstance::StartInstance(uv_loop_s*, int, char const* const*, int, char const* const*) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
27: NodeInstance::StartInstance(int, char**) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
28: NodeInstance::spawnedThread() [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
29: NodeInstance::node_main_task(void*) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
30: void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(void*), void*> >(void*) [/Users/eric/Library/Developer/CoreSimulator/Devices/A78F8FD8-D65E-46F9-9524-2E89CB9FA6F3/data/Containers/Bundle/Application/852EBA4F-6C15-4D9C-9F0E-386A46356080/caramlview.app/Frameworks/LiquidCore.framework/LiquidCore]
31: _pthread_body [/usr/lib/system/libsystem_pthread.dylib]
32: _pthread_start [/usr/lib/system/libsystem_pthread.dylib]
33: thread_start [/usr/lib/system/libsystem_pthread.dylib]

This is a failed assertion in node. Perhaps it is related to the exceptions above, but not sure at this point.

ericwlange commented 5 years ago

I fixed a number of issues that were causing this to fail. There is still a spurious crash that happens in the garbage collector over time, but it more or less works. I am working on this remaining issue.

If you want to try it out, clone the repo and use pod lib lint to make sure everything will build ok.

% git clone https://github.com/LiquidPlayer/LiquidCore.git
% cd LiquidCore
% pod lib lint

Then in your Podfile, include:

  pod 'LiquidCore', :path => 'path/to/LiquidCore/LiquidCore.podspec'

Run pod install and open the created .xcworkspace. You should have the latest build of LiquidCore.

I am using this as my test:

const WebTorrent = require('webtorrent')
const magnetURI = 'magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c&dn=Big+Buck+Bunny&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fbig-buck-bunny.torrent'

let client = new WebTorrent()
client.on('error', e => console.error(e))
client.on('torrent', torrent => {
  console.log('Client is downloading:', torrent.infoHash)
  let progress = 0
  let inte = setInterval(()=>{
    let p = Math.floor(torrent.progress * 100)
    if (p != progress)
      console.log('Progress: ' + String(p) + '%')
    progress = p
    if (torrent.progress >= 1) {
      clearTimeout(inte)
    }
  }, 1000)
})
client.add(magnetURI, {
  path: '/home/local'
})

Console output:

2019-02-04 12:17:10.118604+0100 caramlview[32100:110237674] stdout: Client is downloading: dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c
2019-02-04 12:17:16.314197+0100 caramlview[32100:110237674] stdout: Progress: 1%
2019-02-04 12:17:19.314091+0100 caramlview[32100:110237674] stdout: Progress: 2%
2019-02-04 12:17:22.314046+0100 caramlview[32100:110237674] stdout: Progress: 3%
2019-02-04 12:17:25.314040+0100 caramlview[32100:110237674] stdout: Progress: 4%
2019-02-04 12:17:29.314036+0100 caramlview[32100:110237674] stdout: Progress: 5%
2019-02-04 12:17:32.314196+0100 caramlview[32100:110237674] stdout: Progress: 6%
2019-02-04 12:17:36.324126+0100 caramlview[32100:110237674] stdout: Progress: 7%
2019-02-04 12:17:39.343943+0100 caramlview[32100:110237674] stdout: Progress: 8%
2019-02-04 12:17:43.344432+0100 caramlview[32100:110237674] stdout: Progress: 9%
2019-02-04 12:17:46.355955+0100 caramlview[32100:110237674] stdout: Progress: 10%
2019-02-04 12:17:50.356539+0100 caramlview[32100:110237674] stdout: Progress: 11%
2019-02-04 12:17:53.356452+0100 caramlview[32100:110237674] stdout: Progress: 12%
2019-02-04 12:17:57.356648+0100 caramlview[32100:110237674] stdout: Progress: 13%
2019-02-04 12:18:01.357592+0100 caramlview[32100:110237674] stdout: Progress: 14%
2019-02-04 12:18:04.357615+0100 caramlview[32100:110237674] stdout: Progress: 15%
2019-02-04 12:18:08.357720+0100 caramlview[32100:110237674] stdout: Progress: 16%
2019-02-04 12:18:11.358770+0100 caramlview[32100:110237674] stdout: Progress: 17%
2019-02-04 12:18:15.360117+0100 caramlview[32100:110237674] stdout: Progress: 18%
2019-02-04 12:18:24.360614+0100 caramlview[32100:110237674] stdout: Progress: 19%
2019-02-04 12:18:29.361331+0100 caramlview[32100:110237674] stdout: Progress: 20%
2019-02-04 12:18:33.361933+0100 caramlview[32100:110237674] stdout: Progress: 21%
2019-02-04 12:18:37.367263+0100 caramlview[32100:110237674] stdout: Progress: 22%
2019-02-04 12:18:40.367894+0100 caramlview[32100:110237674] stdout: Progress: 23%
2019-02-04 12:18:44.369075+0100 caramlview[32100:110237674] stdout: Progress: 24%
2019-02-04 12:18:48.369842+0100 caramlview[32100:110237674] stdout: Progress: 25%
2019-02-04 12:18:51.369920+0100 caramlview[32100:110237674] stdout: Progress: 26%
2019-02-04 12:18:55.419618+0100 caramlview[32100:110237674] stdout: Progress: 27%
2019-02-04 12:18:57.432598+0100 caramlview[32100:110237674] stdout: Progress: 28%
2019-02-04 12:19:01.480219+0100 caramlview[32100:110237674] stdout: Progress: 29%
2019-02-04 12:19:04.481119+0100 caramlview[32100:110237674] stdout: Progress: 30%
2019-02-04 12:19:08.526085+0100 caramlview[32100:110237674] stdout: Progress: 31%
2019-02-04 12:19:11.526378+0100 caramlview[32100:110237674] stdout: Progress: 32%
2019-02-04 12:19:15.647952+0100 caramlview[32100:110237674] stdout: Progress: 33%
2019-02-04 12:19:18.647996+0100 caramlview[32100:110237674] stdout: Progress: 34%
2019-02-04 12:19:21.651063+0100 caramlview[32100:110237674] stdout: Progress: 35%
2019-02-04 12:19:25.651460+0100 caramlview[32100:110237674] stdout: Progress: 36%
2019-02-04 12:19:29.663345+0100 caramlview[32100:110237674] stdout: Progress: 37%
2019-02-04 12:19:33.687672+0100 caramlview[32100:110237674] stdout: Progress: 38%
2019-02-04 12:19:36.690627+0100 caramlview[32100:110237674] stdout: Progress: 39%
2019-02-04 12:19:40.691233+0100 caramlview[32100:110237674] stdout: Progress: 40%
2019-02-04 12:19:43.691201+0100 caramlview[32100:110237674] stdout: Progress: 41%
2019-02-04 12:19:47.706143+0100 caramlview[32100:110237674] stdout: Progress: 42%
2019-02-04 12:19:50.707007+0100 caramlview[32100:110237674] stdout: Progress: 43%
2019-02-04 12:19:53.750801+0100 caramlview[32100:110237674] stdout: Progress: 44%
2019-02-04 12:19:57.768395+0100 caramlview[32100:110237674] stdout: Progress: 45%
2019-02-04 12:20:01.770023+0100 caramlview[32100:110237674] stdout: Progress: 46%
2019-02-04 12:20:05.770326+0100 caramlview[32100:110237674] stdout: Progress: 47%
2019-02-04 12:20:08.770504+0100 caramlview[32100:110237674] stdout: Progress: 48%
2019-02-04 12:20:12.770588+0100 caramlview[32100:110237674] stdout: Progress: 49%
2019-02-04 12:20:15.802996+0100 caramlview[32100:110237674] stdout: Progress: 50%
2019-02-04 12:20:19.805657+0100 caramlview[32100:110237674] stdout: Progress: 51%
2019-02-04 12:20:22.805563+0100 caramlview[32100:110237674] stdout: Progress: 52%
2019-02-04 12:20:26.110095+0100 caramlview[32100:110237674] stdout: Progress: 53%
2019-02-04 12:20:29.153021+0100 caramlview[32100:110237674] stdout: Progress: 54%
2019-02-04 12:20:33.231619+0100 caramlview[32100:110237674] stdout: Progress: 55%
2019-02-04 12:20:36.359588+0100 caramlview[32100:110237674] stdout: Progress: 56%
2019-02-04 12:20:40.359738+0100 caramlview[32100:110237674] stdout: Progress: 57%
2019-02-04 12:20:43.359826+0100 caramlview[32100:110237674] stdout: Progress: 58%
2019-02-04 12:20:47.359886+0100 caramlview[32100:110237674] stdout: Progress: 59%
2019-02-04 12:20:50.361099+0100 caramlview[32100:110237674] stdout: Progress: 60%
2019-02-04 12:20:54.361702+0100 caramlview[32100:110237674] stdout: Progress: 61%
2019-02-04 12:20:57.473065+0100 caramlview[32100:110237674] stdout: Progress: 62%
2019-02-04 12:21:01.484004+0100 caramlview[32100:110237674] stdout: Progress: 63%
2019-02-04 12:21:04.483815+0100 caramlview[32100:110237674] stdout: Progress: 64%
2019-02-04 12:21:08.486168+0100 caramlview[32100:110237674] stdout: Progress: 65%
2019-02-04 12:21:11.487420+0100 caramlview[32100:110237674] stdout: Progress: 66%
2019-02-04 12:21:15.488918+0100 caramlview[32100:110237674] stdout: Progress: 67%
2019-02-04 12:21:18.489465+0100 caramlview[32100:110237674] stdout: Progress: 68%
2019-02-04 12:21:22.492227+0100 caramlview[32100:110237674] stdout: Progress: 69%
2019-02-04 12:21:25.492970+0100 caramlview[32100:110237674] stdout: Progress: 70%
2019-02-04 12:21:29.493974+0100 caramlview[32100:110237674] stdout: Progress: 71%
2019-02-04 12:21:32.494181+0100 caramlview[32100:110237674] stdout: Progress: 72%
2019-02-04 12:21:36.496096+0100 caramlview[32100:110237674] stdout: Progress: 73%
Assertion failed: (handles.count(obj)), function DecrementCount, file /Users/eric/workspace/LiquidPlayer/LiquidCore/LiquidCoreiOS/LiquidCore/node-8.9.3/V82JSC/HeapObjects.h, line 139.

I can restart it and it will eventually finish. It downloads the video Big Buck Bunny into /home/public.

Obviously I need to fix the garbage collector, but otherwise this seems to be almost working now.

ericwlange commented 5 years ago

This is now fixed in master.

ericwlange commented 5 years ago

v0.6.0 is now released and this fix is in it.

liurenqiu520 commented 5 years ago

image

i still have problems...

ericwlange commented 5 years ago

Open node_modules/compact2string/index.js

Add the line:

let compact2string

at line 2. So it looks like:

var ipaddr = require('ipaddr.js');
let compact2string
module.exports = compact2string = function (buf) {
  switch(buf.length) {
  case 6:
    return buf[0] + "." + buf[1] + "." + buf[2] + "." + buf[3] + ":" + buf.readUInt16BE(4);
    break;
  case 18:
    var hexGroups = [];
    for(var i = 0; i < 8; i++) {
      hexGroups.push(buf.readUInt16BE(i * 2).toString(16));
    }
    var host = ipaddr.parse(hexGroups.join(":")).toString();
    return "[" + host + "]:" + buf.readUInt16BE(16);
  default:
    throw new Error("Invalid Compact IP/PORT, It should contain 6 or 18 bytes");
  }
};

compact2string.multi = function (buf) {
  if(buf.length % 6 !== 0)
    throw new Error("buf length isn't multiple of compact IP/PORTs (6 bytes)");

  var output = [];
  for (var i = 0; i <= buf.length - 1; i = i + 6) {
    output.push(compact2string(buf.slice(i, i + 6)));
  }

  return output;
};

compact2string.multi6 = function (buf) {
  if(buf.length % 18 !== 0)
    throw new Error("buf length isn't multiple of compact IP6/PORTs (18 bytes)");

  var output = [];
  for (var i = 0; i <= buf.length - 1; i = i + 18) {
    output.push(compact2string(buf.slice(i, i + 18)));
  }

  return output;
};

Then run it again. It should fix the issue.

This is because the metro bundler insists on using "use strict;". The line module.exports = compact2string = function (buf) { is a violation in strict mode because compact2string has not been declared.

ericwlange commented 5 years ago

Incidentally, this has been fixed in compact2string 11 days ago. So you can also just upgrade to version 1.4.1.