Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18323] Windows: UI-related module should be notified when app window is ready

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2015-01-07T01:03:26.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsWindows
Labelsn/a
ReporterIngo Muschenetz
AssigneeIngo Muschenetz
Created2015-01-06T20:54:32.000+0000
Updated2017-03-14T19:13:22.000+0000

Description

Some UI-related modules like Ti.Gesture, Ti.Accelerometer and Ti.Platform.DisplayCaps needs reference to "current display information" (Windows::Graphics::Display::DisplayInformation) to initialize internal state, but currently initializing it at module constructor is causing crash. Let say we have Gesture module and want to get current view after module is initialized, to initialize event listener. We could do it at constructor like below...
c++
  Gesture::Gesture() {
   //  we want display information to initialize orientation event
    const auto display = Windows::Graphics::Display::DisplayInformation::GetForCurrentView();
    display->OrientationChanged += ....
  }
Unfortunately, this ends up crash with following error. Note that WinRT complains about thread usage, but it is not quite right. Seems like problem here is that CoreWindow is not initialized at the moment.
WinRT information: Windows.Graphics.Display: 
GetForCurrentView must be called on a thread that is associated with a CoreWindow.
So, what we actually need is "callback" which is called when window is ready. UI-related module should get notified after window is ready, so that it can setup UI-related stuff safely. It could be something like this:
// override
void Gesture::OnTitaniumMainWindowReady() {
    // ok, now we can get current view safely
    const auto display = Windows::Graphics::Display::DisplayInformation::GetForCurrentView
}

Comments

  1. Kota Iguchi 2015-01-07

    Fixed by PR #51
  2. Lee Morris 2017-03-14

    Closing ticket as fixed.

JSON Source