diff --git a/shell/platform/linux/fl_texture_registrar.cc b/shell/platform/linux/fl_texture_registrar.cc old mode 100755 new mode 100644 index d22e24cf327b0..0be10cb63b98f --- a/shell/platform/linux/fl_texture_registrar.cc +++ b/shell/platform/linux/fl_texture_registrar.cc @@ -98,7 +98,12 @@ static gboolean register_texture(FlTextureRegistrar* registrar, return FALSE; } - int64_t id = self->next_id++; + // We ideally would use numeric IDs, but for backwards compatibility with + // existing code use the address of the texture. Once all code uses + // fl_texture_get_id we can re-enable this method. See + // https://github.com/flutter/flutter/issues/124009 int64_t id = + // self->next_id++; + int64_t id = reinterpret_cast(texture); if (fl_engine_register_external_texture(self->engine, id)) { fl_texture_set_id(texture, id); g_mutex_lock(&self->textures_mutex); diff --git a/shell/platform/linux/fl_texture_registrar_test.cc b/shell/platform/linux/fl_texture_registrar_test.cc index 7f9fdb413ab9a..b020eaa35bcd2 100644 --- a/shell/platform/linux/fl_texture_registrar_test.cc +++ b/shell/platform/linux/fl_texture_registrar_test.cc @@ -71,7 +71,9 @@ static void* add_mock_texture_to_registrar(void* pointer) { FlTextureRegistrar* registrar = FL_TEXTURE_REGISTRAR(pointer); g_autoptr(FlTexture) texture = FL_TEXTURE(fl_test_registrar_texture_new()); fl_texture_registrar_register_texture(registrar, texture); - pthread_exit(NULL); + int64_t* id = static_cast(malloc(sizeof(int64_t))); + id[0] = fl_texture_get_id(texture); + pthread_exit(id); } // Checks can make a mock registrar. @@ -121,6 +123,7 @@ TEST(FlTextureRegistrarTest, RegistrarRegisterTextureInMultipleThreads) { g_autoptr(FlEngine) engine = make_mock_engine(); g_autoptr(FlTextureRegistrar) registrar = fl_texture_registrar_new(engine); pthread_t threads[kThreadCount]; + int64_t ids[kThreadCount]; for (uint64_t t = 0; t < kThreadCount; t++) { EXPECT_EQ(pthread_create(&threads[t], NULL, add_mock_texture_to_registrar, @@ -128,11 +131,13 @@ TEST(FlTextureRegistrarTest, RegistrarRegisterTextureInMultipleThreads) { 0); } for (uint64_t t = 0; t < kThreadCount; t++) { - pthread_join(threads[t], NULL); + void* id; + pthread_join(threads[t], &id); + ids[t] = static_cast(id)[0]; + free(id); }; - // Check the texture named from [1, threadCount]. - for (uint64_t t = 1; t <= kThreadCount; t++) { - EXPECT_TRUE(fl_texture_registrar_lookup_texture(registrar, (int64_t)t) != - NULL); + // Check all the textures were created. + for (uint64_t t = 0; t < kThreadCount; t++) { + EXPECT_TRUE(fl_texture_registrar_lookup_texture(registrar, ids[t]) != NULL); }; }