Merge "Fix a bug in deciding ref frame context in ext-refs" into nextgenv2