| 909 | } |
| 910 | |
| 911 | void AsyncTaskManager::startAsyncExport(ExportFormat format, |
| 912 | const std::filesystem::path& path, |
| 913 | std::vector<ExportSplatSource> splats, |
| 914 | int sh_degree, |
| 915 | bool borrow_single_identity, |
| 916 | std::shared_mutex* model_mutex, |
| 917 | bool rad_flip_y, |
| 918 | bool rad_streamable) { |
| 919 | if (splats.empty()) { |
| 920 | LOG_ERROR("No splat data to export"); |
| 921 | publishExportFailureState(format, path, "No splat data to export"); |
| 922 | return; |
| 923 | } |
| 924 | |
| 925 | export_state_.active.store(true); |
| 926 | export_state_.cancel_requested.store(false); |
| 927 | export_state_.progress.store(0.0f); |
| 928 | { |
| 929 | const std::lock_guard lock(export_state_.mutex); |
| 930 | export_state_.format = format; |
| 931 | export_state_.stage = "Starting"; |
| 932 | export_state_.error.clear(); |
| 933 | export_state_.path = path; |
| 934 | } |
| 935 | publishExportState(); |
| 936 | |
| 937 | LOG_INFO("Export started: {} (format: {})", lfs::core::path_to_utf8(path), static_cast<int>(format)); |
| 938 | |
| 939 | export_state_.thread.emplace( |
| 940 | [this, |
| 941 | format, |
| 942 | path, |
| 943 | splats = std::move(splats), |
| 944 | sh_degree, |
| 945 | borrow_single_identity, |
| 946 | model_mutex, |
| 947 | rad_flip_y, |
| 948 | rad_streamable]( |
| 949 | std::stop_token stop_token) mutable { |
| 950 | bool cancellation_logged = false; |
| 951 | auto update_progress = [this, &stop_token, &cancellation_logged](float progress, const std::string& stage) -> bool { |
| 952 | if (stop_token.stop_requested() || export_state_.cancel_requested.load()) { |
| 953 | if (!cancellation_logged) { |
| 954 | LOG_INFO("Export cancelled"); |
| 955 | cancellation_logged = true; |
| 956 | } |
| 957 | { |
| 958 | const std::lock_guard lock(export_state_.mutex); |
| 959 | export_state_.stage = "Cancelled"; |
| 960 | } |
| 961 | publishExportState(); |
| 962 | if (auto* window_manager = services().windowOrNull()) { |
| 963 | window_manager->wakeEventLoop(); |
| 964 | } |
| 965 | return false; |
| 966 | } |
| 967 | export_state_.progress.store(progress); |
| 968 | { |
nothing calls this directly
no test coverage detected