flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.09k stars 27.43k forks source link

Impeller: Hang in flutter::Rasterizer::Draw pipeline.h / PipelineFuture::Get / _pthread_cond_wait #157860

Open time4tea opened 1 day ago

time4tea commented 1 day ago

Steps to reproduce

There is likely to be a native surface (CALayer) in the tree, drawing video content, when this occurred.

  libsystem_kernel    0x1ef39b08c  __psynch_cvwait
  libsystem_pthread   0x20318f6e0  _pthread_cond_wait
  Flutter             0x10934c7fc  std::_fl::__libcpp_condvar_wait[abi:v15000] (__threading_support:335)
  Flutter             0x10934c7fc  std::_fl::condition_variable::wait (condition_variable.cpp:46)
  Flutter             0x10934cbec  std::_fl::__assoc_sub_state::__sub_wait (future.cpp:160)
  Flutter             0x1093e1244  std::_fl::__assoc_state<T>::copy (future:699)
  Flutter             0x10940f740  std::_fl::shared_future<T>::get[abi:v15000] (future:2243)
  Flutter             0x10940f740  impeller::PipelineFuture<T>::Get (pipeline.h:29)
  Flutter             0x10940f740  impeller::RenderPipelineHandle<T>::WaitAndGet (pipeline.h:128)
  Flutter             0x10940eba0  impeller::ContentContext::GetClipPipeline (content_context.h:498)
  Flutter             0x10940eba0  impeller::ClipContents::Render (clip_contents.cc:178)
  Flutter             0x10945c050  impeller::EntityPass::RenderElement (entity_pass.cc:832)
  Flutter             0x10945b11c  impeller::EntityPass::OnRender (entity_pass.cc:984)
  Flutter             0x1093fdd30  impeller::EntityPass::Render (entity_pass.cc:501)
  Flutter             0x1093fdd30  impeller::AiksContext::Render (aiks_context.cc:61)
  Flutter             0x10946b450  std::_fl::__function::__value_func<T>::operator()[abi:v15000] (function.h:512)
  Flutter             0x10946b450  std::_fl::function<T>::operator() (function.h:1187)
  Flutter             0x10946b450  impeller::Renderer::Render (renderer.cc:46)
  Flutter             0x1098e31f0  flutter::GPUSurfaceMetalImpeller::AcquireFrameFromCAMetalLayer::lambda::operator() (gpu_surface_metal_impeller.mm:191)
  Flutter             0x1098e31f0  fml::internal::CopyableLambda<T>::operator()<T> (make_copyable.h:24)
  Flutter             0x1098e31f0  std::_fl::__invoke[abi:v15000]<T> (invoke.h:403)
  Flutter             0x1098e31f0  std::_fl::__invoke_void_return_wrapper<T>::__call<T> (invoke.h:479)
  Flutter             0x1098e31f0  std::_fl::__function::__alloc_func<T>::operator()[abi:v15000] (function.h:185)
  Flutter             0x1098e31f0  std::_fl::__function::__func<T>::operator() (function.h:359)
  Flutter             0x1097e0874  std::_fl::__function::__value_func<T>::operator()[abi:v15000] (function.h:512)
  Flutter             0x1097e0874  std::_fl::function<T>::operator() (function.h:1187)
  Flutter             0x1097e0874  flutter::SurfaceFrame::PerformSubmit (surface_frame.cc:78)
  Flutter             0x1097e0874  flutter::SurfaceFrame::Submit (surface_frame.cc:56)
  Flutter             0x109324b58  flutter::FlutterPlatformViewsController::SubmitFrame (FlutterPlatformViews.mm:779)
  Flutter             0x109348d88  flutter::IOSExternalViewEmbedder::SubmitFlutterView (ios_external_view_embedder.mm:83)
  Flutter             0x109896880  flutter::Rasterizer::DrawToSurfaceUnsafe (rasterizer.cc:793)
  Flutter             0x109896880  flutter::Rasterizer::DrawToSurfacesUnsafe (rasterizer.cc:658)
  Flutter             0x109896de8  flutter::Rasterizer::DrawToSurfaces::lambda::operator() (rasterizer.cc:597)
  Flutter             0x109896de8  std::_fl::__invoke[abi:v15000]<T> (invoke.h:403)
  Flutter             0x109896de8  std::_fl::__invoke_void_return_wrapper<T>::__call<T> (invoke.h:488)
  Flutter             0x109896de8  std::_fl::__function::__alloc_func<T>::operator()[abi:v15000] (function.h:185)
  Flutter             0x109896de8  std::_fl::__function::__func<T>::operator() (function.h:359)
  Flutter             0x10936c2a4  std::_fl::__function::__value_func<T>::operator()[abi:v15000] (function.h:512)
  Flutter             0x10936c2a4  std::_fl::function<T>::operator() (function.h:1187)
  Flutter             0x10936c2a4  fml::SyncSwitch::Execute (sync_switch.cc)
  Flutter             0x10989602c  flutter::Rasterizer::DrawToSurfaces (rasterizer.cc:589)
  Flutter             0x109897c68  flutter::Rasterizer::DoDraw (rasterizer.cc:491)
  Flutter             0x109897c68  flutter::Rasterizer::Draw::lambda::operator() (rasterizer.cc:259)
  Flutter             0x109897c68  std::_fl::__invoke[abi:v15000]<T> (invoke.h:403)
  Flutter             0x109897c68  std::_fl::__invoke_void_return_wrapper<T>::__call<T> (invoke.h:488)
  Flutter             0x109897c68  std::_fl::__function::__alloc_func<T>::operator()[abi:v15000] (function.h:185)
  Flutter             0x109897c68  std::_fl::__function::__func<T>::operator() (function.h:359)
  Flutter             0x109897484  std::_fl::__function::__value_func<T>::operator()[abi:v15000] (function.h:512)
  Flutter             0x109897484  std::_fl::function<T>::operator() (function.h:1187)
  Flutter             0x109897484  flutter::Pipeline<T>::Consume (pipeline.h:203)
  Flutter             0x109897484  flutter::Rasterizer::Draw (rasterizer.cc:263)
  Flutter             0x10936a854  std::_fl::__function::__value_func<T>::operator()[abi:v15000] (function.h:512)
  Flutter             0x10936a854  std::_fl::function<T>::operator() (function.h:1187)
  Flutter             0x10936a854  fml::MessageLoopImpl::FlushTasks (message_loop_impl.cc:126)
  Flutter             0x10936de58  fml::MessageLoopImpl::RunExpiredTasksNow (message_loop_impl.cc:139)
  Flutter             0x10936de58  fml::MessageLoopDarwin::OnTimerFire (message_loop_darwin.mm:85)
  CoreFoundation      0x1a6774a28  __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
  CoreFoundation      0x1a67746cc  __CFRunLoopDoTimer
  CoreFoundation      0x1a6774228  __CFRunLoopDoTimers
  CoreFoundation      0x1a6710884  __CFRunLoopRun
  CoreFoundation      0x1a670fcd4  CFRunLoopRunSpecific
  GraphicsServices    0x1eb15d1a4  GSEventRunModal
  UIKitCore           0x1a8d49ae4  -[UIApplication _run]
  UIKitCore           0x1a8dfdd94  UIApplicationMain
  UIKitCore           0x1a8f77500  keypath_get_selector_hoverStyle
  Runner              0x104d0c5a4  <redacted>

Device Information: Dart 3.5.4 (stable) Device iPhone 13/D17AP OS iOS 17.6.1/21G93 rooted no locale en_US

Expected results

Should not hang

Actual results

App did hang, and caused automated alerts.

Code sample

Sorry, cannot reproduce with minimal sample.

Screenshots or Video

Sorry Not available

Logs

Not available - production build

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.24.4, on macOS 14.7 23H124 darwin-arm64, locale en-GB) • Flutter version 3.24.4 on channel stable at /Users/jra311/fvm/versions/stable • Upstream repository https://github.com/flutter/flutter.git • Framework revision 603104015d (6 days ago), 2024-10-24 08:01:25 -0700 • Engine revision db49896cf2 • Dart version 3.5.4 • DevTools version 2.37.3 [✓] Xcode - develop for iOS and macOS (Xcode 15.4) • Xcode at /Applications/Xcode-15.app/Contents/Developer • Build 15F31d • CocoaPods version 1.15.2 [✓] Network resources • All expected network resources are available. ```
huycozy commented 1 day ago

Hi @time4tea Are you implementing Platform views in your app? Does the issue only occur in production or also in local environment when running in release mode?

Looking at the trace, this is somewhat similar to https://github.com/flutter/flutter/issues/155247 which is indicated as fixed. You can try switching to Flutter beta or master channel to see if the crash persists or not.

time4tea commented 1 day ago

Hiya. Yes platform views are in use.

Thanks for the link to the other issue although I confess I didn't see the similarity. That appeared to be a crash around a blur function, but this was a hang waiting on a CV?

Unfortunately this is from customer devices and we have not been able to reproduce locally as yet.

huycozy commented 23 hours ago

Thanks for confirming. I will mark this issue for insights from others.