diff --git a/driver/js/include/driver/scope.h b/driver/js/include/driver/scope.h index 480c7602df8..d34c1eb94c6 100644 --- a/driver/js/include/driver/scope.h +++ b/driver/js/include/driver/scope.h @@ -284,8 +284,10 @@ class Scope : public std::enable_shared_from_this { auto task = [weak_this, uri, start, end]() { DEFINE_AND_CHECK_SELF(Scope) auto entry = self->GetPerformance()->PerformanceResource(uri); - entry->SetLoadSourceStart(start); - entry->SetLoadSourceEnd(end); + if (entry) { + entry->SetLoadSourceStart(start); + entry->SetLoadSourceEnd(end); + } }; runner->PostTask(std::move(task)); } diff --git a/framework/android/connector/driver/js/src/main/cpp/src/js_driver_jni.cc b/framework/android/connector/driver/js/src/main/cpp/src/js_driver_jni.cc index cfaed8999e2..a14ee04c95d 100644 --- a/framework/android/connector/driver/js/src/main/cpp/src/js_driver_jni.cc +++ b/framework/android/connector/driver/js/src/main/cpp/src/js_driver_jni.cc @@ -203,8 +203,10 @@ void OnResourceLoadEnd(JNIEnv* j_env, jobject j_object, jint j_scope_id, jstring auto scope = weak_scope.lock(); if (scope) { auto entry = scope->GetPerformance()->PerformanceResource(uri); - entry->SetLoadSourceStart(footstone::TimePoint::FromEpochDelta(footstone::TimeDelta::FromMilliseconds(j_start_time))); - entry->SetLoadSourceEnd(footstone::TimePoint::FromEpochDelta(footstone::TimeDelta::FromMilliseconds(j_end_time))); + if (entry) { + entry->SetLoadSourceStart(footstone::TimePoint::FromEpochDelta(footstone::TimeDelta::FromMilliseconds(j_start_time))); + entry->SetLoadSourceEnd(footstone::TimePoint::FromEpochDelta(footstone::TimeDelta::FromMilliseconds(j_end_time))); + } } }; runner->PostTask(std::move(task));