Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25656] Android. TiViewProxy.getOrCreateView returns null on Titanium 7.0.0+

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-01-25T16:22:35.000+0000
Affected Version/sRelease 7.0.0
Fix Version/sRelease 7.0.2
ComponentsAndroid
LabelsAndroid, development, module
ReporterSergey Volkov
AssigneeGary Mathews
Created2018-01-09T11:16:35.000+0000
Updated2018-01-26T19:11:27.000+0000

Description

Before 7.0.0 "TiViewProxy.getOrCreateView()" never returned "null". Now it does. [Breaking commit](https://github.com/appcelerator/titanium_mobile/commit/58ffbd5147faa90259d805957ab8957c7a84b912#diff-bec22e2efdd8b352a7754ea42f435dc7R487) In attached example I use DrawerLayout, but problem can appear in every module which use "getOrCreateView()" without checking result for "null".

Attachments

FileDateSize
-.txt2018-01-09T11:24:08.000+00008272
app.js2018-01-09T11:09:10.000+00001981

Comments

  1. Sergey Volkov 2018-01-09

    [^-.txt] From https://ti-slack.slack.com/files/U06V3AS8Y/F8LPGH1KQ/-.txt
  2. Hans Knöchel 2018-01-09

    Hey [~s.volkov], thanks for reporting! 7.0.0 was a major release with many breaking changes as described in [semantic versioning](https://semver.org/). Anyway, I don't think this was planned, so I'll move the ticket to have it investigated by the Android team to provide you an alternative. Thanks!
  3. Joshua Quick 2018-01-09

    [~s.volkov], this was done on purpose. It'll only return null if the parent activity was destroyed or was never assigned. This is typically the case when the proxy's view has been released after its parent activity has been destroyed (via the back-button). Once the activity has been destroyed, we cannot create another view since the activity context has been destroyed or else this will lead to other problems (ie: where it's crashing now used to be using destroyed activity contexts). The real issue here is there are place in the code that is missing null checks after an activity has been destroyed. Particularly in handleMessage() method calls which can get invoked by a view/activity/proxy after all UI elements have been released (not a Titanium issue; this is how it works for all native Android developers). Thanks for the stack-trace. We'll use that to fix that specific issue.
  4. Sergey Volkov 2018-01-10

    In example I create proxies while _win2_ is opened, but I don't attach them to _win2_, so no views really created. After _win2_ is closed and this proxies become useless, because activity from _win2_ is destroyed. Maybe we should not assign activity to proxy, before its view created (and use TiApplication.getCurrentActivity() while actual activity not assigned)? P.S. This issue was opened after [this](https://github.com/manumaticx/Ti.DrawerLayout/issues/88) in original Ti.DrawerLayout module.
  5. Sergey Volkov 2018-01-10

    To be clear, [stack trace (-.txt)|^-.txt] is not from [example (app.js) | ^app.js] .
  6. Joshua Quick 2018-01-10

    [~s.volkov], The specific issue here is that the proxy was created and assigned win2's activity (because it was the top-most activity at the time), but the proxy wasn't used and attempted to create its view until after win'2 activity was destroyed (which it still references). Before our code change, it would have created its view based on the destroyed activity, which you can do but there is a high risk of running into illegal-state exceptions. We'll look into an alternative solution. For now, you can work-around this by creating these views at launch. This will work because the root activity which shows the splash screen exists for the lifetime of the JavaScript runtime. Alternatively, create these views during the window's "open" event for the window they're intended to be displayed in (less convenient to code, but it'll work).
  7. Gary Mathews 2018-01-11

    master: https://github.com/appcelerator/titanium_mobile/pull/9721
  8. Lokesh Choudhary 2018-01-12

    [~gmathews], Can you please provide a backport.
  9. Lokesh Choudhary 2018-01-12

    -FR Passed for master. Waiting for merge to get enabled.- Found some issues.
  10. Gary Mathews 2018-01-17

    7_0_X: https://github.com/appcelerator/titanium_mobile/pull/9743
  11. Lokesh Choudhary 2018-01-18

    Found issues in Backport.
  12. Lokesh Choudhary 2018-01-23

    FR passed for backport. Waiting for merge to become enabled.
  13. Lokesh Choudhary 2018-01-24

    Backport PR merged.
  14. Lokesh Choudhary 2018-01-25

    Master PR merged.
  15. Lokesh Choudhary 2018-01-25

    Verified the fix with SDK 7.1.0.v20180125082515 & 7.1.0.v20180125082515. Closing. Studio Ver: 5.0.0.201712081732 OS Ver: 10.13.2 Xcode Ver: Xcode 9.2 Appc NPM: 4.2.11 Appc CLI: 7.0.1 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.10.10 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 1.8.0_101 Devices: ⇨ samsung SM-G955U1 --- Android 7.0 ⇨ google Nexus 5 --- Android 6.0.1 Emulator: android 8.0

JSON Source