RedirectToTypeScriptFinish 设置 FUNC_Native 后补充 Function->Bind()#2340
Closed
chu123122 wants to merge 1 commit into
Closed
RedirectToTypeScriptFinish 设置 FUNC_Native 后补充 Function->Bind()#2340chu123122 wants to merge 1 commit into
chu123122 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
中文 Issue / Draft PR 草稿:RedirectToTypeScriptFinish 设置 FUNC_Native 后补充 Bind
标题
UTypeScriptGeneratedClass::RedirectToTypeScriptFinish()设置FUNC_Native后需要调用Function->Bind()摘要
在 UE 5.7 的最小复现工程里,
UTypeScriptGeneratedClass::RedirectToTypeScriptFinish()会把被重定向的 Blueprint 函数标记为FUNC_Native,但没有在修改 flag 后调用UFunction::Bind()。结果是:UE 的 lifecycle /
ProcessEvent能触发到对应UFunction,但 native dispatch 入口没有重新绑定到 PuerTS 的 JS thunk,最终不会进入 TS/JS 侧函数。在同一份最小复现里,补充:
Function->FunctionFlags |= FUNC_BlueprintCallable | FUNC_BlueprintEvent | FUNC_Public | FUNC_Native; Function->Bind();后,
ReceiveBeginPlay、ReceiveTick、普通实例函数Probe/CustomVoid/ProbeCallsLocal都可以正常进入 TS/JS。当前补丁
分支:
commit:
修改文件:
补丁范围只有一行
Function->Bind(),没有包含诊断日志、测试工程或 hot reload 临时代码。复现环境
a9a5564ed295897cba1e8a57f5021905df72233f5.7.4PuertsBindReproTickProbe extends UE.ActorReceiveBeginPlay/ReceiveTickProcessEvent:Probe/CustomVoid/ProbeCallsLocal失败现象
无
Function->Bind()时:TickProbe_Cactor 可以创建。ProcessEvent Probe/ProcessEvent CustomVoid/ProcessEvent ProbeCallsLocal。[TickProbe] Probe .../[TickProbe] CustomVoid .../[TickProbe] ProbeCallsLocal ...。[TickProbe] BeginPlay .../[TickProbe] Tick ...。关键日志:
注意:
REINST_... Failed to bind native function在加补丁后仍可能出现,所以它不能单独作为最终失败判据。真正判据是最终 actor 的 lifecycle /ProcessEvent后是否进入 TS/JS 日志。通过现象
加
Function->Bind()后,最终 actorTickProbe_C输出:Phase 7 使用 clean branch patch 复测日志:
影响范围说明
这不是声明“所有 PuerTS 函数路径都有问题”。
当前已经验证的范围是:
FunctionToRedirect。RedirectToTypeScriptFinish()收尾。ProcessEvent调度的 redirectedUFunction。当前没有验证的范围:
源码上,本补丁只在
RedirectToTypeScriptFinish()内、FunctionToRedirect.Contains(...)命中的函数上调用Bind()。不走该 finish 路径的函数不会执行新增代码。运行对照上,无 Bind 时
[TickProbe] Constructor probe-v2已经能输出,但 lifecycle /ProcessEvent函数不进入 JS,说明问题集中在 redirectedUFunctionnative dispatch,而不是 JS 环境整体不可用。和 PR #2339 的关系
PR #2339 解决的是另一个相关但不同的问题:引入新的 import 后,TS 代码热编译时,继承自 UObject 的 TS 类没有完成强制 reinject / prototype 链刷新,导致现有对象仍使用旧逻辑。
本补丁不替代 PR #2339,也不解决新增 import 的 module cache / hot reload 问题。
更准确的关系是:
UTypeScriptGeneratedClass/ prototype 链刷新问题。RedirectToTypeScriptFinish()设置FUNC_Native后,UE native dispatch 入口没有重新Bind()的问题。两个问题在热重载 / 重新生成 BP 场景下可能一起暴露,但修复点不同。
建议提交方式
当前建议先开 Issue 或 Draft PR,不建议直接开正式 PR。
原因:
Bind()调用是否符合他们对所有支持 UE 版本的预期。如果开 Draft PR,建议标题限定为:
正文避免写“修复所有 PuerTS 函数不生效”,而写: