Skip to content

Temporary fix for the invalid tbm_surface error #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

swift-kim
Copy link
Member

@swift-kim swift-kim commented May 3, 2021

This partially reverts the change of #67.

Video frames are not displayed if the ref count is not properly increased (tbm_surface_internal_ref).

E/TBM     ( 4840): [634776.838197][4903][_tbm_surface_internal_is_valid 269]error: No valid tbm_surface(0xb2a04fb8)
E/TBM     ( 4840): [634776.838288][4903][tbm_surface_internal_get_info 1284]'_tbm_surface_internal_is_valid(surface)' failed.
D/ConsoleMessage( 4840): external_texture_gl.cc: PopulateTextureWithIdentifier(83) > tbm_surface not valid
...(repeats)

The internal APIs tbm_surface_internal_ref and tbm_surface_internal_unref cannot be used in wearable profile so we need a better solution than this change.

@xuelian-bai @xiaowei-guan @bwikbs Could you take a look if you have any idea?

cc @bbrto21

@bwikbs
Copy link
Member

bwikbs commented May 3, 2021

@swift-kim I'm sorry for making you misunderstand. This part of the evasgl renderer is unfinished work. I had a plan to discuss with the video plugin team to remove the internal api, but I didn't...

IMO, This issue is caused by a mismatch between what we get from the decoder(media_packet) and what we use at API(tbm_surface_h ). So I think adding an interface for media_packet could be a solution.

Here's a rough idea that I had at that time.

  • Interface
FLUTTER_EXPORT int64_t
FlutterRegisterExternalTexture(FlutterTextureRegistrarRef texture_registrar, int texture_type);

FLUTTER_EXPORT bool FlutterMarkExternalTextureFrameAvailable(
    FlutterTextureRegistrarRef texture_registrar, int64_t texture_id,
    void* [tbm_surface or media_packet]);
void VideoPlayer::onVideoFrameDecoded(media_packet_h packet, void *data) {
/*
  VideoPlayer *player = (VideoPlayer *)data;
  tbm_surface_h surface;
  int ret = media_packet_get_tbm_surface(packet, &surface);
  if (ret != MEDIA_PACKET_ERROR_NONE) {
    LOG_ERROR(
        "[VideoPlayer.onVideoFrameDecoded] media_packet_get_tbm_surface "
        "failed, error: %d",
        ret);
    media_packet_destroy(packet);
    return;
  }
*/
  FlutterMarkExternalTextureFrameAvailable(player->textureRegistrar_,
                                           player->textureId_, packet);
  // media_packet_destroy(packet);
}
void ExternalTextureGL::DestructionTbmSurface() {
  if (!texture_tbm_surface_) {
    FT_LOGE("tbm_surface_h is NULL");
    return;
  }
  // tbm_surface_destroy(texture_tbm_surface_);
 media_packet_destroy(texture_tbm_surface_);
  texture_tbm_surface_ = NULL;
}

Of course, this type of processing should be in both media_packet and tbm.

@xuelian-bai
Copy link

tbm_surface_internal_ref and tbm_surface_internal_unref are used to lock/unlock the tbm surface from free by mmplayer, so they can't be deleted. Except these two APIs, we can also use tbm_surface_map/tbm_surface_unmap to lock/unlock surface, but they are expensive.

@swift-kim
Copy link
Member Author

Superseded by #81.

@swift-kim swift-kim closed this May 6, 2021
@xuelian-bai
Copy link

@bwikbs I didn't get it. You use media_packet instead of tbm surface, but how to generate texture by using media_packet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants