Opened on 03/27/2018 at 12:50:33 PM

Last modified on 06/22/2018 at 06:37:06 AM

#6529 new change

Use prebuilt V8 from libadblockplus-binaries in Chromium

Reported by: asmirnov Assignee:
Priority: P4 Milestone:
Module: Adblock-Plus-for-Chromium Keywords:
Cc: sergz Blocked By:
Blocking: Platform: Android
Ready: no Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

https://gitlab.com/eyeo/adblockplus/chromium/merge_requests/12

Description (last modified by sergz)

Background

libadlockplus requires V8 to run JS. We do provide precompiled V8 in libadblockplus-binaries for libadblockplus-android to link it as shared library (libadblockplus-jni.so). For this we don't have to update V8 - it just works.

But for using libadblockplus + libadblockplus-android in Chromium with Chromium's V8 we have to make sure we can use Chromium's V8 (sometimes significant changes are done, e.g. changing Android NDK version). But we may want to avoid updating it every time it's changed in Chromium and having both V8 in the final apk. This obviously increases the final apk size but helps to reduce the amount of work required to either update Chromium with V8 or integrated adblockplus. In the former one has to basically do nothing in order to migrate libadblockplus + libadblockplus-android into newer Chromium. In the latter it helps to reduce the time needed to update libadblockplus + libadblockplus-android in Chromium.

Sergei is 90% sure both V8 can live together in the same Chromium process if our V8 is statically linked with our .so file.

What to do

We need to link libadblockplus-android with prebuilt V8 from -binaries (statically) and ensure (check) that it can work in Chromium context (having both Chromium V8 and libadblockplus prebuilt V8).

Attachments (5)

v8_crash.txt.zip (68.1 KB) - added by asmirnov on 04/03/2018 at 01:35:32 PM.
v8_crash2.txt.zip (94.0 KB) - added by asmirnov on 04/04/2018 at 05:53:58 AM.
crash with recompiled v8 (now without changes in https://codereview.adblockplus.org/29733646/), previous crash log was retrieved for apk with that code review changed applied.
0001-Issue-6529-Use-prebuilt-V8-from-libadblockplus-binar.patch (10.3 KB) - added by asmirnov on 04/04/2018 at 07:03:15 AM.
patch file to compile it with V8 from -binaries
brief_log.txt (11.4 KB) - added by asmirnov on 04/13/2018 at 11:11:02 AM.
full_log.txt (69.9 KB) - added by asmirnov on 04/13/2018 at 11:11:19 AM.

Download all attachments as: .zip

Change History (14)

comment:1 Changed on 03/27/2018 at 01:03:21 PM by sergz

  • Description modified (diff)

comment:2 Changed on 03/27/2018 at 01:15:28 PM by sergz

  • Description modified (diff)

comment:3 Changed on 04/03/2018 at 01:34:54 PM by asmirnov

Compiled with V8 from libadblockplus-binaries apk crashes (see attachment).

Changed on 04/03/2018 at 01:35:32 PM by asmirnov

comment:4 Changed on 04/03/2018 at 01:36:01 PM by asmirnov

04-03 17:53:52.365 297-297 I/DEBUG:     r0 aead2010  r1 0000000c  r2 00000000  r3 0007bd00
04-03 17:53:52.365 297-297 I/DEBUG:     r4 00000018  r5 aead2010  r6 aead2010  r7 0000000c
04-03 17:53:52.365 297-297 I/DEBUG:     r8 9fdb2d10  r9 00000000  sl aead2000  fp 9ebd00d4
04-03 17:53:52.365 297-297 I/DEBUG:     ip b3c4aa98  sp b3c4aa48  lr 9f540c7c  pc 9f5671d4  cpsr 80030010
04-03 17:53:52.365 297-297 I/DEBUG: backtrace:
04-03 17:53:52.365 297-297 I/DEBUG:     #00 pc 004bf1d4  /data/app/org.chromium.chrome-1/lib/arm/libadblockplus-jni.so (v8::internal::Heap::AllocateRawOneByteString(int, v8::internal::PretenureFlag)+296)
04-03 17:53:52.365 297-297 I/DEBUG:     #01 pc 00498c78  /data/app/org.chromium.chrome-1/lib/arm/libadblockplus-jni.so (v8::internal::Factory::NewRawOneByteString(int, v8::internal::PretenureFlag)+36)
04-03 17:53:52.365 297-297 I/DEBUG:     #02 pc 00498658  /data/app/org.chromium.chrome-1/lib/arm/libadblockplus-jni.so (v8::internal::Factory::NewStringFromOneByte(v8::internal::Vector<unsigned char const>, v8::internal::PretenureFlag)+56)
04-03 17:53:52.365 297-297 I/DEBUG:     #03 pc 004999bc  /data/app/org.chromium.chrome-1/lib/arm/libadblockplus-jni.so (v8::internal::Factory::NewStringFromUtf8(v8::internal::Vector<char const>, v8::internal::PretenureFlag)+452)
04-03 17:53:52.365 297-297 I/DEBUG:     #04 pc 00339d20  /data/app/org.chromium.chrome-1/lib/arm/libadblockplus-jni.so (v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::String::NewStringType, int)+156)
04-03 17:53:52.365 297-297 I/DEBUG:     #05 pc 00e4e65f  /data/app/org.chromium.chrome-1/lib/arm/libchrome.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #06 pc 0022d551  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so (v8::internal::Compiler::GetSharedFunctionInfoForNative(v8::Extension*, v8::internal::Handle<v8::internal::String>)+60)
04-03 17:53:52.365 297-297 I/DEBUG:     #07 pc 004bda43  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #08 pc 004bd7f5  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #09 pc 004d33cd  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #10 pc 00228571  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so (v8::internal::CompilationJob::FinalizeJob()+104)
04-03 17:53:52.365 297-297 I/DEBUG:     #11 pc 0022df9d  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #12 pc 00229589  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #13 pc 0022b3d5  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #14 pc 0022c963  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so (v8::internal::Compiler::GetSharedFunctionInfoForScript(v8::internal::Handle<v8::internal::String>, v8::internal::MaybeHandle<v8::internal::Object>, int, int, v8::ScriptOriginOptions, v8::internal::MaybeHandle<v8::internal::Object>, v8::internal::Handle<v8::internal::Context>, v8::Extension*, v8::internal::ScriptData**, v8::ScriptCompiler::CompileOptions, v8::internal::NativesFlag, v8::internal::MaybeHandle<v8::internal::FixedArray>)+
04-03 17:53:52.365 297-297 I/DEBUG:     #15 pc 00192007  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #16 pc 001986fb  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #17 pc 00198369  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #18 pc 0017e5cd  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #19 pc 0017e525  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #20 pc 0011ea81  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #21 pc 000f9a2b  /data/app/org.chromium.chrome-1/lib/arm/libv8.cr.so (v8::Context::New(v8::Isolate*, v8::ExtensionConfiguration*, v8::MaybeLocal<v8::ObjectTemplate>, v8::MaybeLocal<v8::Value>, v8::DeserializeInternalFieldsCallback)+14)
04-03 17:53:52.365 297-297 I/DEBUG:     #22 pc 0051b5ab  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #23 pc 0051b063  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #24 pc 0053b151  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #25 pc 00520303  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #26 pc 008062ff  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so (blink::LocalFrame::WindowProxy(blink::DOMWrapperWorld&)+2)
04-03 17:53:52.365 297-297 I/DEBUG:     #27 pc 0052dd0d  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so (blink::ToV8ContextEvenIfDetached(blink::LocalFrame*, blink::DOMWrapperWorld&)+48)
04-03 17:53:52.365 297-297 I/DEBUG:     #28 pc 0052dc87  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #29 pc 0052dd39  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so (blink::ToScriptState(blink::LocalFrame*, blink::DOMWrapperWorld&)+24)
04-03 17:53:52.365 297-297 I/DEBUG:     #30 pc 006a8c67  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so (blink::ClassicPendingScript::StartStreamingIfPossible(blink::ScriptStreamer::Type, WTF::Function<void (), (WTF::FunctionThreadAffinity)1>)+62)
04-03 17:53:52.365 297-297 I/DEBUG:     #31 pc 0092125b  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #32 pc 00920a0b  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #33 pc 0092080f  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #34 pc 00914d19  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so (blink::HTMLDocumentParser::RunScriptsForPausedTreeBuilder()+76)
04-03 17:53:52.365 297-297 I/DEBUG:     #35 pc 009158b5  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so (blink::HTMLDocumentParser::ProcessTokenizedChunkFromBackgroundParser(std::__ndk1::unique_ptr<blink::HTMLDocumentParser::TokenizedChunk, std::__ndk1::default_delete<blink::HTMLDocumentParser::TokenizedChunk> >)+992)
04-03 17:53:52.365 297-297 I/DEBUG:     #36 pc 00914bf9  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so (blink::HTMLDocumentParser::PumpPendingSpeculations()+432)
04-03 17:53:52.365 297-297 I/DEBUG:     #37 pc 00914a31  /data/app/org.chromium.chrome-1/lib/arm/libblink_core.cr.so (blink::HTMLDocumentParser::ResumeParsingAfterYield()+116)
04-03 17:53:52.365 297-297 I/DEBUG:     #38 pc 001663d1  /data/app/org.chromium.chrome-1/lib/arm/libblink_platform.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #39 pc 00166221  /data/app/org.chromium.chrome-1/lib/arm/libblink_platform.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #40 pc 0008cb4d  /data/app/org.chromium.chrome-1/lib/arm/libbase.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #41 pc 00095d5b  /data/app/org.chromium.chrome-1/lib/arm/libbase.cr.so (base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*)+78)
04-03 17:53:52.365 297-297 I/DEBUG:     #42 pc 0030839f  /data/app/org.chromium.chrome-1/lib/arm/libblink_platform.cr.so (blink::scheduler::TaskQueueManager::ProcessTaskFromWorkQueue(blink::scheduler::internal::WorkQueue*, bool, blink::scheduler::LazyNow, base::TimeTicks*)+598)
04-03 17:53:52.365 297-297 I/DEBUG:     #43 pc 0030727d  /data/app/org.chromium.chrome-1/lib/arm/libblink_platform.cr.so (blink::scheduler::TaskQueueManager::DoWork(bool)+532)
04-03 17:53:52.365 297-297 I/DEBUG:     #44 pc 0008cb4d  /data/app/org.chromium.chrome-1/lib/arm/libbase.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #45 pc 00095d5b  /data/app/org.chromium.chrome-1/lib/arm/libbase.cr.so (base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*)+78)
04-03 17:53:52.365 297-297 I/DEBUG:     #46 pc 000ac231  /data/app/org.chromium.chrome-1/lib/arm/libbase.cr.so (base::internal::IncomingTaskQueue::RunTask(base::PendingTask*)+60)
04-03 17:53:52.365 297-297 I/DEBUG:     #47 pc 000adf37  /data/app/org.chromium.chrome-1/lib/arm/libbase.cr.so (base::MessageLoop::RunTask(base::PendingTask*)+174)
04-03 17:53:52.365 297-297 I/DEBUG:     #48 pc 000ae1b5  /data/app/org.chromium.chrome-1/lib/arm/libbase.cr.so (base::MessageLoop::DeferOrRunPendingTask(base::PendingTask)+80)
04-03 17:53:52.365 297-297 I/DEBUG:     #49 pc 000ae291  /data/app/org.chromium.chrome-1/lib/arm/libbase.cr.so (base::MessageLoop::DoWork()+176)
04-03 17:53:52.365 297-297 I/DEBUG:     #50 pc 000af5fb  /data/app/org.chromium.chrome-1/lib/arm/libbase.cr.so (base::MessagePumpDefault::Run(base::MessagePump::Delegate*)+108)
04-03 17:53:52.365 297-297 I/DEBUG:     #51 pc 000add3b  /data/app/org.chromium.chrome-1/lib/arm/libbase.cr.so (base::MessageLoop::Run()+58)
04-03 17:53:52.365 297-297 I/DEBUG:     #52 pc 000c5823  /data/app/org.chromium.chrome-1/lib/arm/libbase.cr.so (base::RunLoop::Run()+70)
04-03 17:53:52.365 297-297 I/DEBUG:     #53 pc 00bcfb47  /data/app/org.chromium.chrome-1/lib/arm/libcontent.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #54 pc 00ca5623  /data/app/org.chromium.chrome-1/lib/arm/libcontent.cr.so
04-03 17:53:52.365 297-297 I/DEBUG:     #55 pc 0000fdb9  /data/app/org.chromium.chrome-1/lib/arm/libembedder.cr.so (service_manager::Main(service_manager::MainParams const&)+604)
04-03 17:53:52.365 297-297 I/DEBUG:     #56 pc 00ca4d47  /data/app/org.chromium.chrome-1/lib/arm/libcontent.cr.so (Java_org_chromium_content_app_ContentMain_nativeStart+174)
04-03 17:53:52.365 297-297 I/DEBUG:     #57 pc 00207d71  /data/dalvik-cache/arm/data@app@org.chromium.chrome-1@base.apk@classes.dex

comment:5 Changed on 04/03/2018 at 01:36:59 PM by asmirnov

.so looks good - does not require any v8 libs (linked statically), is large enough (contains V8 from -binaries):

antoine@antoine-vm:~/temp$ readelf -d ./libadblockplus-jni.so | grep NEEDED
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so]
 0x00000001 (NEEDED)                     Shared library: [libm.so]
 0x00000001 (NEEDED)                     Shared library: [libc.so]
 0x00000001 (NEEDED)                     Shared library: [libdl.so]
antoine@antoine-vm:~/temp$ ls -l ./libadblockplus-jni.so 
-rw-rw-r-- 1 antoine antoine 13688080 апр.   3 17:57 ./libadblockplus-jni.so

Last edited on 04/03/2018 at 01:37:22 PM by asmirnov

comment:6 Changed on 04/03/2018 at 01:38:35 PM by asmirnov

It looks like it's using Chromium V8 (libv8.cr.so instead of v8 from libadblockplus-jni.so)

Changed on 04/04/2018 at 05:53:58 AM by asmirnov

crash with recompiled v8 (now without changes in https://codereview.adblockplus.org/29733646/), previous crash log was retrieved for apk with that code review changed applied.

Changed on 04/04/2018 at 07:03:15 AM by asmirnov

patch file to compile it with V8 from -binaries

comment:7 Changed on 04/05/2018 at 10:31:40 AM by asmirnov

yes, libadblockplus-jni.so contains v8:

antoine@antoine-vm:~/temp$ head -10 | readelf -Ws ./libadblockplus-jni.so | grep v8 | head -10
   530: 0034ec68   152 FUNC    GLOBAL DEFAULT   12 _ZN2v87Context4ExitEv
   531: 00322a90    56 FUNC    GLOBAL DEFAULT   12 _ZN2v811HandleScopeD1Ev
   532: 003460dc     4 FUNC    GLOBAL DEFAULT   12 _ZN2v87Isolate4ExitEv
   533: 006b7660   172 FUNC    GLOBAL DEFAULT   12 _ZN2v86LockerD1Ev
   548: 006b72f8   224 FUNC    GLOBAL DEFAULT   12 _ZN2v86Locker10InitializeEPNS_7IsolateE
   549: 003460d8     4 FUNC    GLOBAL DEFAULT   12 _ZN2v87Isolate5EnterEv
   550: 00322a7c    20 FUNC    GLOBAL DEFAULT   12 _ZN2v811HandleScopeC1EPNS_7IsolateE
   551: 00322aec    72 FUNC    GLOBAL DEFAULT   12 _ZN2v811HandleScope12CreateHandleEPNS_8internal7IsolateEPNS1_6ObjectE
   552: 00322d14    88 FUNC    GLOBAL DEFAULT   12 _ZN2v87Context5EnterEv
   554: 00345ebc   124 FUNC    GLOBAL DEFAULT   12 _ZN2v87Isolate7DisposeEv

comment:8 Changed on 04/13/2018 at 11:09:00 AM by asmirnov

  • Review URL(s) modified (diff)

Changed on 04/13/2018 at 11:11:02 AM by asmirnov

Changed on 04/13/2018 at 11:11:19 AM by asmirnov

comment:9 Changed on 06/22/2018 at 06:37:06 AM by asmirnov

Starting Chromium 67 with update libadblockplus this should be easier now.
One have to adjust only V8 headers and binaries path. And v8 should be built as shared libraries for this.

Add Comment

Modify Ticket

Change Properties
Action
as new .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from (none).
Next status will be 'reviewing'.
 
Note: See TracTickets for help on using tickets.