Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ed80d63 authored by Jeremy Meyer's avatar Jeremy Meyer
Browse files

Pass a copy of style_id_args to theme.rebase()

This is because "the native code should not run for an extended period
of time before it calls ReleasePrimitiveArrayCritical" and
Theme.rebase() can take longer than we would like.

Bug: 242005877
Test: relying on presubmit tests
Change-Id: Idff98afb84fea4944a592939212f5c57e822ae2f
parent b3b7c4d9
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -1293,6 +1293,10 @@ static void NativeThemeRebase(JNIEnv* env, jclass /*clazz*/, jlong ptr, jlong th
  } else {
    CHECK(style_count == 0) << "style_ids is null while style_count is non-zero";
  }
  auto style_id_args_copy = std::vector<uint32_t>{style_id_args, style_id_args + style_count};
  if (style_ids != nullptr) {
      env->ReleasePrimitiveArrayCritical(style_ids, style_id_args, JNI_ABORT);
  }

  jboolean* force_args = nullptr;
  if (force != nullptr) {
@@ -1305,15 +1309,14 @@ static void NativeThemeRebase(JNIEnv* env, jclass /*clazz*/, jlong ptr, jlong th
  } else {
    CHECK(style_count == 0) << "force is null while style_count is non-zero";
  }

  auto theme = reinterpret_cast<Theme*>(theme_ptr);
  theme->Rebase(&(*assetmanager), style_id_args, force_args, static_cast<size_t>(style_count));
  if (style_ids != nullptr) {
    env->ReleasePrimitiveArrayCritical(style_ids, style_id_args, JNI_ABORT);
  }
  auto force_args_copy = std::vector<jboolean>{force_args, force_args + style_count};
  if (force != nullptr) {
    env->ReleasePrimitiveArrayCritical(force, force_args, JNI_ABORT);
  }

  auto theme = reinterpret_cast<Theme*>(theme_ptr);
  theme->Rebase(&(*assetmanager), style_id_args_copy.data(), force_args_copy.data(),
                static_cast<size_t>(style_count));
}

static void NativeThemeCopy(JNIEnv* env, jclass /*clazz*/, jlong dst_asset_manager_ptr,