Track::range_of_all_children silently skips a child that is neither an Item nor a Transition, so child_at_time returns nothing and no error

Đang mở
#2,108 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
64/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
data

Hướng nghiên cứu

Start by reading the Track::range_of_all_children() loop in src/opentimelineio/track.cpp (lines 221-271) against Track::range_of_child_at_index() and Composable::duration() in composable.cpp, which already reports OBJECT_WITHOUT_DURATION. Reproduce with the supplied C++ program, then decide and implement consistent behavior: either propagate an error for the plain Composable, or make child_at_time() return the covering Gap. Add a regression test covering the three-child track and confirm it fails before the fix and passes after.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Required:


[x] I believe this isn't a duplicate topic
[x] This report is not related to an adapter

Select One:

[ ] Build problem
[x] Incorrect Functionality or bug
[ ] New feature or functionality

Description

A Track whose children are a 24-frame Gap, a plain Composable, and another 24-frame Gap loads without error. On that track:

  • range_of_all_children() returns 2 entries for 3 children and no error;
  • child_at_time(RationalTime(12, 24)) returns no child and no error, although the first Gap covers frames 0 to 24.

The documentation allows any Composable as a Track child (otio-timeline-structure.md, line 156): "The children of a Track can be any Composable object", and Composable has a public constructor in C++ and Python. child_at_time is documented as (composition.h, line 137):

/// @brief Return the child that overlaps with the given time.

For the same kind of child, the sibling function Track::range_of_child_at_index() reports an error: it calls child->duration(error_status) (track.cpp, lines 64-69), and Composable::duration() sets OBJECT_WITHOUT_DURATION, "Cannot determine duration from this kind of object" (composable.cpp, lines 64-75). Stack::range_of_all_children() goes through the same call (stack.cpp, lines 64-80).

Expected: either range_of_all_children() (and so child_at_time()) reports an error such as OBJECT_WITHOUT_DURATION, as range_of_child_at_index() does for this child, or child_at_time(12@24) returns the first Gap. A null result with no error looks wrong in both readings. If a plain Composable is not meant to be a Track child, an error on load or insert would also make that clear.

Suggestion for the cause: the loop in Track::range_of_all_children() (track.cpp, lines 221-271) only handles Transition and Item, with no else, so any other child gets no map entry and no error. child_at_time() then reads range_map[child], which creates an empty 0-to-0 range for that child and breaks the sorted search (composition.cpp, lines 504-546).

Reproduction Steps

Build against the C++ library (opentimelineio) and run. The program writes the track to a small .otio JSON file, loads it with SerializableObject::from_json_file, then queries it.

#include <opentimelineio/composition.h>
#include <opentimelineio/gap.h>
#include <opentimelineio/serializableObject.h>
#include <opentimelineio/track.h>
#include <opentimelineio/version.h>

#include <cstdio>
#include <cstring>

using namespace OTIO_NS;
using OTIOError = OTIO_NS::ErrorStatus;

// Track: Gap [0,24)@24, a plain Composable, Gap [0,24)@24
static const char* JSON =
    "{\"OTIO_SCHEMA\":\"Track.1\",\"children\":["
    "{\"OTIO_SCHEMA\":\"Gap.1\",\"source_range\":{\"OTIO_SCHEMA\":\"TimeRange.1\","
    "\"start_time\":{\"OTIO_SCHEMA\":\"RationalTime.1\",\"rate\":24,\"value\":0},"
    "\"duration\":{\"OTIO_SCHEMA\":\"RationalTime.1\",\"rate\":24,\"value\":24}}},"
    "{\"OTIO_SCHEMA\":\"Composable.1\"},"
    "{\"OTIO_SCHEMA\":\"Gap.1\",\"source_range\":{\"OTIO_SCHEMA\":\"TimeRange.1\","
    "\"start_time\":{\"OTIO_SCHEMA\":\"RationalTime.1\",\"rate\":24,\"value\":0},"
    "\"duration\":{\"OTIO_SCHEMA\":\"RationalTime.1\",\"rate\":24,\"value\":24}}}],"
    "\"kind\":\"Video\"}";

int
main()
{
    const char* path = "bad_track.json";
    if (FILE* f = fopen(path, "wb"))
    {
        fwrite(JSON, 1, strlen(JSON), f);
        fclose(f);
    }
    else
    {
        printf("SETUP-FAIL cannot write %s\n", path);
        return 2;
    }

    OTIOError           pe;
    SerializableObject* so = SerializableObject::from_json_file(path, &pe);
    if (is_error(pe) || !so)
    {
        printf("SETUP-FAIL from_json_file: %s\n", pe.full_description.c_str());
        return 2;
    }
    Track* t = dynamic_cast<Track*>(so);
    if (!t)
    {
        printf("SETUP-FAIL not a Track\n");
        return 2;
    }
    printf(
        "loaded %s: Track with %zu children, load errors=%d\n",
        path,
        t->children().size(),
        (int) is_error(pe));

    OTIOError re;
    auto      m = t->range_of_all_children(&re);
    printf(
        "range_of_all_children: entries=%zu of %zu children, error=%d (%s)\n",
        m.size(),
        t->children().size(),
        (int) is_error(re),
        re.full_description.c_str());

    OTIOError ce;
    auto      c = t->child_at_time(RationalTime(12, 24), &ce);
    printf(
        "child_at_time(12@24) -> child=%s error=%d (%s)\n",
        c.value ? c.value->schema_name().c_str() : "null",
        (int) is_error(ce),
        ce.full_description.c_str());

    // the first child is a Gap spanning [0,24)@24, which contains 12@24
    bool first_is_gap = dynamic_cast<Gap*>(t->children()[0].value) != nullptr;
    if (!c.value && !is_error(ce))
    {
        printf(
            "FAIL: file-driven child_at_time(12@24) returned no child and no error, though children[0] is a Gap (=%d) spanning [0,24)@24 which contains 12@24\n",
            (int) first_is_gap);
        return 1;
    }
    printf("ok\n");
    return 0;
}

The same happens with a track built in code (insert_child of a Gap, new Composable(), a Gap): child_at_time(12@24) returns no child and no error, while the same track with only the two Gaps returns the first Gap.

Log output if appropriate

Observed:

loaded bad_track.json: Track with 3 children, load errors=0
range_of_all_children: entries=2 of 3 children, error=0 ()
child_at_time(12@24) -> child=null error=0 ()
FAIL: file-driven child_at_time(12@24) returned no child and no error, though children[0] is a Gap (=1) spanning [0,24)@24 which contains 12@24

Expected: either an error is reported (error=1, for example OBJECT_WITHOUT_DURATION) by range_of_all_children and child_at_time, or child_at_time(12@24) returns the first Gap and the program prints ok.

Optional


Environment

OpenTimelineIO main at bad7ab5a40ac1a95d9d78a87c95a688d8b57cf28, and run again at f6c34bc6c3337cdd27db77c983c6074130c1c91c (20 Nov 2026) with the same result, C++ library opentimelineio.
Operating System: Windows, MSVC (Visual Studio 2022 Build Tools), the project's CMake build in Debug configuration with AddressSanitizer (/fsanitize=address).
Python version if appropriate: n/a (C++ API).

Found by VaultLens, an analysis tool that uses AI to catch bugs. If anything is wrong, please let us know.

Ngôn ngữ chính
C++
Star
2.1k
Fork
367
Merge trung bình
3 ngày 22 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AcademySoftwareFoundation/OpenTimelineIO

Tất cả issue của AcademySoftwareFoundation/OpenTimelineIO

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.