@@ -34,7 +34,7 @@ static IPCSender *sSender;
34
34
static std::unique_ptr<IPCHandler> sHandler ;
35
35
static std::unique_ptr<WeexJSConnection> sConnection ;
36
36
static WEEX_CORE_JS_SERVER_API_FUNCTIONS *js_server_api_functions = nullptr ;
37
- bool g_use_single_process = true ;
37
+ bool g_use_single_process = false ;
38
38
39
39
namespace WeexCore {
40
40
void WeexProxy::reset () {
@@ -122,7 +122,11 @@ namespace WeexCore {
122
122
}
123
123
124
124
jint
125
- WeexProxy::initFrameworkInMultiProcess (JNIEnv *env, jstring script, jobject params) {
125
+ WeexProxy::initFrameworkInMultiProcess (JNIEnv *env, jstring script, jobject params,
126
+ IPCSerializer *serializer) {
127
+
128
+ IPCSerializer *realSerializer = nullptr ;
129
+ std::unique_ptr<IPCSerializer> serializerTemp (createIPCSerializer ());
126
130
bool reinit = false ;
127
131
startInitFrameWork:
128
132
try {
@@ -138,6 +142,15 @@ namespace WeexCore {
138
142
return false ;
139
143
}
140
144
} else {
145
+ if (reinit) {
146
+ initFromParam (env, script,
147
+ params,
148
+ serializerTemp.get ());
149
+ realSerializer = serializerTemp.get ();
150
+ } else {
151
+ realSerializer = serializer;
152
+ }
153
+
141
154
// initHandler(sHandler.get());
142
155
143
156
ExtendJSApi *pExtensionJSApi = new ExtendJSApi ();
@@ -146,11 +159,8 @@ namespace WeexCore {
146
159
147
160
// using base::debug::TraceEvent;
148
161
// TraceEvent::StartATrace(env);
149
- std::unique_ptr<IPCSerializer> serializer (createIPCSerializer ());
150
- initFromParam (env, script, params, serializer.get ());
151
- serializer->setMsg (static_cast <uint32_t >(IPCJSMsg::INITFRAMEWORK));
152
-
153
- std::unique_ptr<IPCBuffer> buffer = serializer->finish ();
162
+ realSerializer->setMsg (static_cast <uint32_t >(IPCJSMsg::INITFRAMEWORK));
163
+ std::unique_ptr<IPCBuffer> buffer = realSerializer->finish ();
154
164
std::unique_ptr<IPCResult> result = sSender ->send (buffer.get ());
155
165
if (result->getType () != IPCType::INT32) {
156
166
LOGE (" initFramework Unexpected result type" );
@@ -179,27 +189,32 @@ namespace WeexCore {
179
189
jobject params) {
180
190
181
191
Bridge_Impl_Android::getInstance ()->setGlobalRef (jThis);
192
+ std::unique_ptr<IPCSerializer> serializer (createIPCSerializer ());
193
+ const std::vector<INIT_FRAMEWORK_PARAMS *> &initFrameworkParams = initFromParam (env,
194
+ script,
195
+ params,
196
+ serializer.get ());
197
+ LOGE (" Single process ? %s" , g_use_single_process ? " true" : " false" );
198
+ if (g_use_single_process) {
199
+ if (initFrameworkInSingleProcess (env, script, initFrameworkParams)) {
200
+ // reportNativeInitStatus("-1011", "init Single Process Success");
201
+ return true ;
202
+ }
182
203
183
- LOGE (" doInitFramework is running" );
184
- // if (g_use_single_process) {
185
- // if (initFrameworkInSingleProcess(env, script, nullptr)) {
186
- // //reportNativeInitStatus("-1011", "init Single Process Success");
187
- // return true;
188
- // }
189
- //
190
- // if (initFrameworkInMultiProcess(env, script, params)) {
191
- // return true;
192
- // }
193
- // } else {
194
- if (initFrameworkInMultiProcess (env, script, params)) {
195
- return true ;
204
+ if (initFrameworkInMultiProcess (env, script, params, serializer.get ())) {
205
+ return true ;
206
+ }
207
+ } else {
208
+ if (initFrameworkInMultiProcess (env, script, params, serializer.get ())) {
209
+ return true ;
210
+ }
211
+
212
+ if (initFrameworkInSingleProcess (env, script, initFrameworkParams)) {
213
+ reportNativeInitStatus (" -1011" , " init Single Process Success" );
214
+ return true ;
215
+ }
196
216
}
197
217
198
- // if (initFrameworkInSingleProcess(env, script, nullptr)) {
199
- // reportNativeInitStatus("-1011", "init Single Process Success");
200
- // return true;
201
- // }
202
- // }
203
218
reportNativeInitStatus (" -1010" , " init Failed" );
204
219
return false ;
205
220
@@ -445,7 +460,8 @@ namespace WeexCore {
445
460
callDIspatchMessage
446
461
};
447
462
448
- auto *functions = (WEEX_CORE_JS_API_FUNCTIONS *) malloc (sizeof (WEEX_CORE_JS_API_FUNCTIONS));
463
+ auto *functions = (WEEX_CORE_JS_API_FUNCTIONS *) malloc (
464
+ sizeof (WEEX_CORE_JS_API_FUNCTIONS));
449
465
450
466
if (!functions) {
451
467
return nullptr ;
@@ -461,11 +477,8 @@ namespace WeexCore {
461
477
WEEX_CORE_JS_API_FUNCTIONS *functions);
462
478
463
479
jint
464
- WeexProxy::initFrameworkInSingleProcess (JNIEnv *env, jstring script, jobject params) {
465
- std::unique_ptr<IPCSerializer> serializer (createIPCSerializer ());
466
- const std::vector<INIT_FRAMEWORK_PARAMS *> &initFrameworkParams = initFromParam (env, script,
467
- params,
468
- serializer.get ());
480
+ WeexProxy::initFrameworkInSingleProcess (JNIEnv *env, jstring script,
481
+ const std::vector<INIT_FRAMEWORK_PARAMS *> initFrameworkParams) {
469
482
std::string soPath = " " ;
470
483
471
484
// -----------------------------------------------
@@ -918,7 +931,8 @@ namespace WeexCore {
918
931
if (jTypeInt == 1 ) {
919
932
if (jDoubleValueMethodId == NULL ) {
920
933
jclass jDoubleClazz = env->FindClass (" java/lang/Double" );
921
- jDoubleValueMethodId = env->GetMethodID (jDoubleClazz, " doubleValue" , " ()D" );
934
+ jDoubleValueMethodId = env->GetMethodID (jDoubleClazz, " doubleValue" ,
935
+ " ()D" );
922
936
env->DeleteLocalRef (jDoubleClazz);
923
937
}
924
938
jdouble jDoubleObj = env->CallDoubleMethod (jDataObj, jDoubleValueMethodId);
@@ -1164,7 +1178,8 @@ namespace WeexCore {
1164
1178
}
1165
1179
1166
1180
jstring
1167
- WeexProxy::execJSOnInstance (JNIEnv *env, jobject jcaller, jstring instanceId, jstring script,
1181
+ WeexProxy::execJSOnInstance (JNIEnv *env, jobject jcaller, jstring instanceId,
1182
+ jstring script,
1168
1183
jint type) {
1169
1184
if (instanceId == NULL || script == NULL ) {
1170
1185
return env->NewStringUTF (" " );
@@ -1250,7 +1265,8 @@ namespace WeexCore {
1250
1265
if (jTypeInt == 1 ) {
1251
1266
if (jDoubleValueMethodId == NULL ) {
1252
1267
jclass jDoubleClazz = env->FindClass (" java/lang/Double" );
1253
- jDoubleValueMethodId = env->GetMethodID (jDoubleClazz, " doubleValue" , " ()D" );
1268
+ jDoubleValueMethodId = env->GetMethodID (jDoubleClazz, " doubleValue" ,
1269
+ " ()D" );
1254
1270
env->DeleteLocalRef (jDoubleClazz);
1255
1271
}
1256
1272
jdouble jDoubleObj = env->CallDoubleMethod (jDataObj, jDoubleValueMethodId);
@@ -1481,7 +1497,8 @@ namespace WeexCore {
1481
1497
if (jTypeInt == 1 ) {
1482
1498
if (jDoubleValueMethodId == NULL ) {
1483
1499
jclass jDoubleClazz = env->FindClass (" java/lang/Double" );
1484
- jDoubleValueMethodId = env->GetMethodID (jDoubleClazz, " doubleValue" , " ()D" );
1500
+ jDoubleValueMethodId = env->GetMethodID (jDoubleClazz, " doubleValue" ,
1501
+ " ()D" );
1485
1502
env->DeleteLocalRef (jDoubleClazz);
1486
1503
}
1487
1504
jdouble jDoubleObj = env->CallDoubleMethod (jDataObj, jDoubleValueMethodId);
@@ -1532,7 +1549,8 @@ namespace WeexCore {
1532
1549
ScopedJStringUTF8 instanceId (env, jinstanceid);
1533
1550
ScopedJStringUTF8 funcChar (env, jfunction);
1534
1551
return js_server_api_functions->funcCallJSOnAppContext (instanceId.getChars (),
1535
- funcChar.getChars (), params);
1552
+ funcChar.getChars (),
1553
+ params);
1536
1554
} else {
1537
1555
std::unique_ptr<IPCBuffer> buffer = serializer->finish ();
1538
1556
std::unique_ptr<IPCResult> result = sSender ->send (buffer.get ());
0 commit comments