[Flutter GPU] Fix assert failure in createDeviceBufferWithCopy. (flutter/engine#56039)
Resolves https://github.com/flutter/flutter/issues/157336 `DartByteData` gets raw pointers into the Dart heap via `Dart_TypedDataAcquireData`. So it must be destructed before `AssociateWithDartWrapper` is called, which mutates the heap. Re-enables failing test for Linux unopt.
This commit is contained in:
@@ -74,12 +74,18 @@ bool InternalFlutterGpu_DeviceBuffer_InitializeWithHostData(
|
||||
Dart_Handle wrapper,
|
||||
flutter::gpu::Context* gpu_context,
|
||||
Dart_Handle byte_data) {
|
||||
auto data = tonic::DartByteData(byte_data);
|
||||
auto mapping = fml::NonOwnedMapping(reinterpret_cast<uint8_t*>(data.data()),
|
||||
data.length_in_bytes());
|
||||
auto device_buffer =
|
||||
gpu_context->GetContext()->GetResourceAllocator()->CreateBufferWithCopy(
|
||||
mapping);
|
||||
std::shared_ptr<impeller::DeviceBuffer> device_buffer = nullptr;
|
||||
{
|
||||
// `DartByteData` gets raw pointers into the Dart heap via
|
||||
// `Dart_TypedDataAcquireData`. So it must be destructed before
|
||||
// `AssociateWithDartWrapper` is called, which mutates the heap.
|
||||
auto data = tonic::DartByteData(byte_data);
|
||||
auto mapping = fml::NonOwnedMapping(reinterpret_cast<uint8_t*>(data.data()),
|
||||
data.length_in_bytes());
|
||||
device_buffer =
|
||||
gpu_context->GetContext()->GetResourceAllocator()->CreateBufferWithCopy(
|
||||
mapping);
|
||||
}
|
||||
if (!device_buffer) {
|
||||
FML_LOG(ERROR) << "Failed to create device buffer with copy.";
|
||||
return false;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
// ignore_for_file: avoid_relative_lib_imports
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
@@ -398,13 +397,6 @@ void main() async {
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/157324
|
||||
test('Can bind uniforms in range', () async {
|
||||
// TODO(bdero): createDeviceBufferWithCopy triggers an assert in
|
||||
// third_party/dart on Linux.
|
||||
// https://github.com/flutter/flutter/issues/157336
|
||||
if (Platform.isLinux) {
|
||||
return;
|
||||
}
|
||||
|
||||
final state = createSimpleRenderPass();
|
||||
|
||||
final gpu.RenderPipeline pipeline = createUnlitRenderPipeline();
|
||||
|
||||
Reference in New Issue
Block a user